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

Home > Just Math
Digital sum (Posted on 2005-08-20) Difficulty: 2 of 5
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.4000 (5 votes)

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

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       .9976062440232454
1999954       30            9.313225746154785D-10       .997606244954568
1999955       31            4.656612873077393D-10       .9976062454202292
1999956       30            9.313225746154785D-10       .9976062463515518
1999957       31            4.656612873077393D-10       .9976062468172131
1999958       31            4.656612873077393D-10       .9976062472828744
1999959       32            2.328306436538696D-10       .997606247515705
1999960       30            9.313225746154785D-10       .9976062484470276
1999961       31            4.656612873077393D-10       .9976062489126889
1999962       31            4.656612873077393D-10       .9976062493783502
1999963       32            2.328306436538696D-10       .9976062496111808
1999964       31            4.656612873077393D-10       .9976062500768421
1999965       32            2.328306436538696D-10       .9976062503096728
1999966       32            2.328306436538696D-10       .9976062505425034
1999967       33            1.164153218269348D-10       .9976062506589187
1999968       29            1.862645149230957D-09       .9976062525215639
1999969       30            9.313225746154785D-10       .9976062534528864
1999970       30            9.313225746154785D-10       .997606254384209
1999971       31            4.656612873077393D-10       .9976062548498703
1999972       30            9.313225746154785D-10       .9976062557811929
1999973       31            4.656612873077393D-10       .9976062562468542
1999974       31            4.656612873077393D-10       .9976062567125155
1999975       32            2.328306436538696D-10       .9976062569453461
1999976       30            9.313225746154785D-10       .9976062578766687
1999977       31            4.656612873077393D-10       .99760625834233
1999978       31            4.656612873077393D-10       .9976062588079913
1999979       32            2.328306436538696D-10       .9976062590408219
1999980       31            4.656612873077393D-10       .9976062595064832
1999981       32            2.328306436538696D-10       .9976062597393138
1999982       32            2.328306436538696D-10       .9976062599721445
1999983       33            1.164153218269348D-10       .9976062600885598
1999984       30            9.313225746154785D-10       .9976062610198824
1999985       31            4.656612873077393D-10       .9976062614855437
1999986       31            4.656612873077393D-10       .9976062619512049
1999987       32            2.328306436538696D-10       .9976062621840356
1999988       31            4.656612873077393D-10       .9976062626496969
1999989       32            2.328306436538696D-10       .9976062628825275
1999990       32            2.328306436538696D-10       .9976062631153582
1999991       33            1.164153218269348D-10       .9976062632317735
1999992       31            4.656612873077393D-10       .9976062636974348
1999993       32            2.328306436538696D-10       .9976062639302654
1999994       32            2.328306436538696D-10       .9976062641630961
1999995       33            1.164153218269348D-10       .9976062642795114
1999996       32            2.328306436538696D-10       .997606264512342
1999997       33            1.164153218269348D-10       .9976062646287573
1999998       33            1.164153218269348D-10       .9976062647451727
1999999       34            5.820766091346741D-11       .9976062648033803
2000000       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 S
1             2             .25           .25
2             3             .125          .375
3             4             .0625         .4375
4             4             .0625         .5
5             5             .03125        .53125
6             5             .03125        .5625
7             6             .015625       .578125
8             5             .03125        .609375
9             6             .015625       .625
10            6             .015625       .640625
11            7             .0078125      .6484375
12            6             .015625       .6640625
13            7             .0078125      .671875
14            7             .0078125      .6796875
15            8             .00390625     .68359375
16            6             .015625       .69921875
17            7             .0078125      .70703125
18            7             .0078125      .71484375
19            8             .00390625     .71875
20            7             .0078125      .7265625
21            8             .00390625     .73046875
22            8             .00390625     .734375
23            9             .001953125    .736328125
24            7             .0078125      .744140625
25            8             .00390625     .748046875
26            8             .00390625     .751953125
27            9             .001953125    .75390625
28            8             .00390625     .7578125
29            9             .001953125    .759765625
30            9             .001953125    .76171875
31            10            .0009765625   .7626953125
32            7             .0078125      .7705078125
33            8             .00390625     .7744140625
34            8             .00390625     .7783203125
35            9             .001953125    .7802734375
36            8             .00390625     .7841796875
37            9             .001953125    .7861328125
38            9             .001953125    .7880859375
39            10            .0009765625   .7890625
40            8             .00390625     .79296875

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

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (23)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information