Thread: Find the Value View Single Post
2007-07-10, 00:27   #6
m_f_h

Feb 2007

1101100002 Posts

Quote:
 Originally Posted by Orgasmic Troll if n = 999, then we have 99 0s from the ones digit and 90 0s from the tens digit if n = 9999, we have 999 0s from the ones digit, 990 0s from the tens digit and 900 0s from the hundreds digit
Code:
gp > ^Z
Suspended
(mfh@lx08 ~/NumberTheory/PARI) php
<?=($a=count_chars(join(range(0,99))))?$a[48]:0,"
",($a=count_chars(join(range(0,999))))?$a[48]:0,"
",($a=count_chars(join(range(0,9999))))?$a[48]:0,"
";^D
10
190
2890
(mfh@lx08 ~/NumberTheory/PARI) fg
gp
gp > calc0mfh(k)=k*10^(k-1)-(10^k-1)/9+1
time = 0 ms.
gp > calc0mfh(3)
time = 0 ms.
%216 = 190
gp > calc0mfh(4)
time = 0 ms.
%217 = 2890
gp >
thus, the correct formula is:
number of '0's in {0,1,...,10^(k+1)-1} = k*10^(k-1)-(10^k-1)/9+1

I confirm your value for k=11 which is correct, i.e. seems to include the +1 already.
If your "iterations"(?) are ok, the result should be correct.

Last fiddled with by m_f_h on 2007-07-10 at 01:26