For Spriggsy:
Don't know why Pete didn't fix it himself, too tired?
I think Pete is looking for a routine to do roots he can translate to string math. I don't get the Binomial Theorem reference either but the code does get the first digits of 10^.3333... and some other like n = 5 or 27 or .027 or 125 (but not 125^3) but no decimal placements.
Code: (Select All)
$Console:Only
Dim As Double d, h, i, j, n, r
n = 10: root = 3
For g = 1 To 5 ' Just do 5 iterations with no decimal point for this demo.
Print "working number ="; n
If h = 0 Then
Print "Initial loop..."
For h = 1 To 10
If h ^ root > n Then Exit For
Next
h = h - 1
x = h ^ root ' This is the answer digit for the first iteration.
Else
For h = 1 To 10
j = h * (((root * (i * 10 ^ (root - 2))) * ((i * 10 ^ (root - 2)) + h) + h ^ (root - 1)))
Print h; i, j; "<>"; n
If j > n Then Exit For
Next
h = h - 1
d = i * (10 ^ (root - 2))
Color 2: Print "d ="; d, "h ="; h: Color 7
x = h * (((root * d) * (d + h) + h ^ (root - 1)))
End If
Print "Number to subtract ="; x
Rem i = i * (10 ^ (root - 2)) + h
i = Val(LTrim$(Str$(i)) + LTrim$(Str$(h)))
Color 14: Print " i as digits ="; i: Color 7
r = (n - x)
n = r * 10 ^ root
Print "Remainder ="; r ' This is the remainder.
Print "n ="; n; " d ="; d; " h ="; h; "remainder ="; r; "Answer ="; i
Next
Don't know why Pete didn't fix it himself, too tired?
Quote:I do not understand your problem. Why about the extensions of the binomial theorem? You can easily calculate the cube root with the now well-known formula. Or am I misunderstanding the question?
I think Pete is looking for a routine to do roots he can translate to string math. I don't get the Binomial Theorem reference either but the code does get the first digits of 10^.3333... and some other like n = 5 or 27 or .027 or 125 (but not 125^3) but no decimal placements.
b = b + ...