If n is how high many terms is used per factor (largest number whose square root is taken):
n resulting product
2 1
3 64
4 4096.00000000002
5 23323703840.9999
6 6.37034642160154E+25
7 3.16699666163359E+59
For n>5 we don't really have an indication whether the function results in an integer or not, but below 6 it looks as if the non-integral part is a result of rounding error. For n>4 they are not necessarily powers of 2; the numbers for n=5 through 7 definitely are not.
For n=5 the factors are (just as a check):
-4.14626436994197
-.682162754804218
-1.31783724519578
2.14626436994197
-2.14626436994197
1.31783724519578
.682162754804218
4.14626436994197
DefDbl A-Z
Dim crlf$, n
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For n = 2 To 7
prod = 1
ReDim term(n)
For i = 1 To n
term(i) = Sqr(i)
Next
For f = 0 To Int(2 ^ n - 0.5)
tot = 0
bs$ = "": f1 = f
Do
d = f1 Mod 2: f1 = f1 \ 2
bs = LTrim(Str(d)) + bs
Loop Until f1 = 0
bs = Right(String(n, "0") + bs, n)
For i = 1 To Len(bs)
If Mid(bs, i, 1) = "0" Then
tot = tot - term(i)
Else
tot = tot + term(i)
End If
Next
prod = prod * tot
If n = 3 Then
Text1.Text = Text1.Text & Str(tot) & crlf
End If
Next
Text1.Text = Text1.Text & n & Str(prod) & crlf
Next n
Text1.Text = Text1.Text & crlf & " done"
End Sub
I don't really have time today to redo the project in UBASIC to get higher precision, to assure the integral nature for a couple more levels of n. But even if done in UBASIC, we couldn't get even close to 100, due to time and precision limitations.
|
Posted by Charlie
on 2015-09-18 12:37:49 |