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

Home > Just Math
a) is easy, b) is not (Posted on 2011-02-18) Difficulty: 3 of 5
1, 2, 4, 8, 1, 3, 6, 1 ... is a non-cyclic series where a(n) represents the leading digit of 2^n.

a) How many ones are there within the first 3000 members?
b) Same question for a digit d, other than digit one.

No Solution Yet Submitted by Ady TZIDON    
Rating: 3.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution 2 computer ways | Comment 5 of 8 |

DEFDBL A-Z
log10 = LOG(10)
log2 = LOG(2) / LOG(10)

FOR n = 1 TO 3000
  l = n * log2
  l = l - INT(l)
  p = INT(10 ^ l + 9.999999999999999D-12)
  ct(p) = ct(p) + 1
NEXT
FOR i = 1 TO 9
  PRINT i, ct(i), ct(i) / 3000
NEXT

finds

n           number      fraction of the numbers
1             903           .301
2             529           .1763333333333333
3             374           .1246666666666667
4             291           .097
5             238           7.933333333333334D-02
6             201           .067
7             173           5.766666666666666D-02
8             155           5.166666666666667D-02
9             136           4.533333333333334D-02

The fudge factor added by

p = INT(10 ^ l + 9.999999999999999D-12)

was necessary as it was misreporting 8 itself as 7 due to rounding error that made 2^3 come out as something like 7.999999999999.

 5   dim Ct(9)
10   for N=1 to 3000
20    S=cutspc(str(2^N))
30    Ct(val(left(S,1)))=Ct(val(left(S,1)))+1
40   next
50   for I=1 to 9:print I,Ct(I),Ct(I)/3000,tab(40),(log(I+1)-log(I))/log(10):next

finds

n     number      fraction                        expected fraction
1       903     0.301                           0.3010299956639811951
2       529     0.1763333333333333332           0.1760912590556812419
3       374     0.1246666666666666666           0.1249387366082999532
4       291     0.097                           0.0969100130080564141
5       238     0.0793333333333333332           0.0791812460476248277
6       201     0.067                           0.066946789630613198
7       173     0.0576666666666666666           0.0579919469776867551
8       155     0.0516666666666666666           0.0511525224473812888
9       136     0.0453333333333333332           0.0457574905606751253

The expected fraction column is that based on the logs of the digits as per Benford's law.


  Posted by Charlie on 2011-02-18 18:39:55
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


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

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