All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Digital sum (Posted on 2005-08-20)
For each positive integer n, let A(n) be the number of digits in the binary representation of n, and let B(n) be the number of ones in the binary representation of n. What is the value of S:

S = (1/2)^[A(1)+B(1)] + (1/2)^[A(2)+B(2)] + (1/2)^[A(3)+B(3)] + ...

 See The Solution Submitted by pcbouhid Rating: 4.2500 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 Looks suspiciously close to ... | Comment 1 of 7

It looks suspiciously close to 1, but I wouldn't know why.

Carried to n = 2,000,000,   for which the power of 1/2 is 28 and the added term is 3.725290298461914*10^9, the total is .9976062685286706, as shown in the final few lines to which the program was allowed to run:

`1999953       30            9.313225746154785D-10       .99760624402324541999954       30            9.313225746154785D-10       .9976062449545681999955       31            4.656612873077393D-10       .99760624542022921999956       30            9.313225746154785D-10       .99760624635155181999957       31            4.656612873077393D-10       .99760624681721311999958       31            4.656612873077393D-10       .99760624728287441999959       32            2.328306436538696D-10       .9976062475157051999960       30            9.313225746154785D-10       .99760624844702761999961       31            4.656612873077393D-10       .99760624891268891999962       31            4.656612873077393D-10       .99760624937835021999963       32            2.328306436538696D-10       .99760624961118081999964       31            4.656612873077393D-10       .99760625007684211999965       32            2.328306436538696D-10       .99760625030967281999966       32            2.328306436538696D-10       .99760625054250341999967       33            1.164153218269348D-10       .99760625065891871999968       29            1.862645149230957D-09       .99760625252156391999969       30            9.313225746154785D-10       .99760625345288641999970       30            9.313225746154785D-10       .9976062543842091999971       31            4.656612873077393D-10       .99760625484987031999972       30            9.313225746154785D-10       .99760625578119291999973       31            4.656612873077393D-10       .99760625624685421999974       31            4.656612873077393D-10       .99760625671251551999975       32            2.328306436538696D-10       .99760625694534611999976       30            9.313225746154785D-10       .99760625787666871999977       31            4.656612873077393D-10       .997606258342331999978       31            4.656612873077393D-10       .99760625880799131999979       32            2.328306436538696D-10       .99760625904082191999980       31            4.656612873077393D-10       .99760625950648321999981       32            2.328306436538696D-10       .99760625973931381999982       32            2.328306436538696D-10       .99760625997214451999983       33            1.164153218269348D-10       .99760626008855981999984       30            9.313225746154785D-10       .99760626101988241999985       31            4.656612873077393D-10       .99760626148554371999986       31            4.656612873077393D-10       .99760626195120491999987       32            2.328306436538696D-10       .99760626218403561999988       31            4.656612873077393D-10       .99760626264969691999989       32            2.328306436538696D-10       .99760626288252751999990       32            2.328306436538696D-10       .99760626311535821999991       33            1.164153218269348D-10       .99760626323177351999992       31            4.656612873077393D-10       .99760626369743481999993       32            2.328306436538696D-10       .99760626393026541999994       32            2.328306436538696D-10       .99760626416309611999995       33            1.164153218269348D-10       .99760626427951141999996       32            2.328306436538696D-10       .9976062645123421999997       33            1.164153218269348D-10       .99760626462875731999998       33            1.164153218269348D-10       .99760626474517271999999       34            5.820766091346741D-11       .99760626480338032000000       28            3.725290298461914D-09       .9976062685286706`

The program is:

DECLARE FUNCTION cvb\$ (n#)
DECLARE FUNCTION ct1# (s\$)
DEFDBL A-Z
s = 0
t = 1
DO
b\$ = cvb\$(t)
pwr = (LEN(b\$) + ct1(b\$))
term = .5 ^ pwr
s = s + term
PRINT t, pwr, term, s
t = t + 1
ct = ct + 1
'IF ct MOD 40 = 0 THEN DO: LOOP UNTIL INKEY\$ > ""
LOOP

FUNCTION ct1 (s\$)
ct = 0
FOR i = 1 TO LEN(s\$)
IF MID\$(s\$, i, 1) = "1" THEN ct = ct + 1
NEXT
ct1 = ct
END FUNCTION

FUNCTION cvb\$ (n)
b\$ = "": n2 = n
DO
q = n2 2: r = n2 MOD 2
b\$ = LTRIM\$(STR\$(r)) + b\$
n2 = q
LOOP UNTIL n2 = 0
cvb\$ = b\$
END FUNCTION

For verification, the first few lines of output are:

`n          A(n)+B(n)     .5^(A(n)+B(n)   partial S1             2             .25           .252             3             .125          .3753             4             .0625         .43754             4             .0625         .55             5             .03125        .531256             5             .03125        .56257             6             .015625       .5781258             5             .03125        .6093759             6             .015625       .62510            6             .015625       .64062511            7             .0078125      .648437512            6             .015625       .664062513            7             .0078125      .67187514            7             .0078125      .679687515            8             .00390625     .6835937516            6             .015625       .6992187517            7             .0078125      .7070312518            7             .0078125      .7148437519            8             .00390625     .7187520            7             .0078125      .726562521            8             .00390625     .7304687522            8             .00390625     .73437523            9             .001953125    .73632812524            7             .0078125      .74414062525            8             .00390625     .74804687526            8             .00390625     .75195312527            9             .001953125    .7539062528            8             .00390625     .757812529            9             .001953125    .75976562530            9             .001953125    .7617187531            10            .0009765625   .762695312532            7             .0078125      .770507812533            8             .00390625     .774414062534            8             .00390625     .778320312535            9             .001953125    .780273437536            8             .00390625     .784179687537            9             .001953125    .786132812538            9             .001953125    .788085937539            10            .0009765625   .789062540            8             .00390625     .79296875`

Edited on August 20, 2005, 7:10 pm
 Posted by Charlie on 2005-08-20 18:54:22

 Search: Search body:
Forums (0)