Live data from Hacker News

Fun with math: Dividing one by 998001 yields a surprising result

iheartchaos.com

31–40 of 99 posts

Re: Fun with math: Dividing one by 998001 yields a surprising result

#32
post #20
post #5

I was searching for some iOS documentation and found this and it's totally ruined my productivity! Can anyone explain why it repeats in this way, or link to a place that has an explanation?

For x < 1, 1 + 2x + 3x^2 + 4x^3 + ... converges to 1/(1-x)^2. When x = 0.001, you get 1/.999^2 = 1000000/998001 = 1.002003004005...

Here is a more detailed explanation

1---------

If x = 0.001 then the sum x^2 + 2x^3 + 3x^4…. in its decimal places will have all the three digit numbers except the the second last starting with 000,001 and then till 997,999.

As pointed out by someone below,the reason 998 is missing is because after 997998999 the next coefficient is 1000.This overflow 1 will carry over and mess up all the nines to the right until it hits the eight at which point it will make it a 9.Therefore the series will become 997999000001002003... as subsequent overflows keep messing up the last digit to the left.During the addition of the 2000th term a similar thing will happen and the series at that location will become ...997999001002003...... and it will keep losing a term from the beginning in the subsequent 998 repetitions.

More generally if x = 10^-n,n>0 then the sum x^2 + 2x^3 + 3x^4 will have all the n digit numbers starting with (n-zeroes),(n-1 zeroes 1)…except the second last (10^n-2).

2---------

From http://en.wikipedia.org/wiki/Geometric_series

An infinite geometric series converges to a/(1-r) if and only if the absolute value of r is less than 1.

a + ar^2 + ar^3 .... = a/(1-r) if |r| [1]

3---------

1 + 2x + 3x^2.....

= (1) + (x+x) + (x^2+x^2+x^2)....

= (1+x+x^2...) + (x+x^2+x^3...) + ...

= 1/(1-x) + x/(1-x) + (x^2)/(1-x) + .... since x = (1+x+x^2....)/(1-x)

= 1/(1-x)^2 since x [2]

4---------

So the number 0.000001002003004……997999000001002003....

= (x^2 + 2x^3 + 3x^4…..) , x = 0.001

= (x^2) * (1 + 2x + 3x^2 …..)

= (x^2)/((1-x)^2)

= (0.001)^2/(0.999)^2

= ((1/999))^2

= 1/998001

More generally the sum which has all the n digit numbers except (10^n-2) in its decimal places is given by (10^n-1)^(-2).

Re: Fun with math: Dividing one by 998001 yields a surprising result

#33

There's some sleight of hand here. Not all the digits are exactly right. Look how it skips from 997 to 999: http://www.futilitycloset.com/2012/01/08/math-notes-76/ Here's the math. Suppose you want a unit fraction 1/n with decimals that cycle through the 4-digit sequence abcd. Multiply by 10^4 to shift abcd into integer position, leaving repeating copies after the decimal point: 10^4/n = abcd + 1/n Solving for n give…

I just want to know I appreciate you posting this. Some people might be interested in "wow math sure can do some funky stuff", but others like myself really want to know why. I figure that's also covers a sizable group of us here on Hacker News.

Re: Fun with math: Dividing one by 998001 yields a surprising result

#34
post #16

Earlier quoted context omitted.

The period is 2997, so set precision to 2997 if you want to see the repeat. Also, "998" doesn't appear 'in sequence' (it obviously appears as 97[9 98]0 981).

Edit: That's strange, about 998 being absent. What follows is definitely nonsense: Don't really have time to think about this, but you can sort of generate the sum (ie by looking at the pattern) with (1/1000) * sum i * 1000^-i , i = 0 to infinity You could try and do a sum of a sum of geometric series and make it work http://www.wolframalpha.com/input/?i=sum+i+*+1000%5E-i%2C+i%... (998001 / 2997 = 3)

It's necessary that one number is absent. The period is 2997 as he mentions. Can't pack 1000 3 digit numbers into that ;)

Re: Fun with math: Dividing one by 998001 yields a surprising result

#36

There's no 998 (and it's not a rounding issue)! ... 995 996 997 999

Yes, that is funky.

  def long_div(x,y,N=10):
    """Given two integers x and y, return us the N digits of x/y."""
    #First work out the integer part
    x = int(x)
    divisor = y = int(y)
    quotients = [x/y]
    dividend = x % y
    for digit in range(N):
      dividend *= 10
      quotient = dividend/divisor
      dividend = dividend%divisor
      quotients.append(quotient)
  
    return quotients
  
  def pretty_print(quotients, G=3):
    """Pretty print quotients by grouping digits by 3."""
    strp = ''
    cnt = 1
    for n in quotients[1:]:
      strp += str(n)
      cnt +=1
      if cnt > G:
        print strp
        strp = ''
        cnt = 1
  
  
  quotients = long_div(1,998001,N=3000)
  pretty_print(quotients,G=3)

Re: Fun with math: Dividing one by 998001 yields a surprising result

#38

The link is blocked at my workplace. I really don't understand how their filter system works.

Ha ha, mine too. It says it's "adult content".

There's a special place in hell for business owners who inflict Websense or any other method of censoring content on their own employees.

If you don't trust me to use it, don't give me a computer, or an internet connection.

Re: Fun with math: Dividing one by 998001 yields a surprising result

#39
post #16

Earlier quoted context omitted.

Edit: That's strange, about 998 being absent. What follows is definitely nonsense: Don't really have time to think about this, but you can sort of generate the sum (ie by looking at the pattern) with (1/1000) * sum i * 1000^-i , i = 0 to infinity You could try and do a sum of a sum of geometric series and make it work http://www.wolframalpha.com/input/?i=sum+i+*+1000%5E-i%2C+i%... (998001 / 2997 = 3)

It's necessary that one number is absent. The period is 2997 as he mentions. Can't pack 1000 3 digit numbers into that ;)

Chuck Norris could :P

Re: Fun with math: Dividing one by 998001 yields a surprising result

#40
... and 1/9999999800000001 = .00000000 00000001 00000002 00000003 00000004 00000005 00000006 ... 99999996 99999997 99999999 ...repeating

Basically, the pattern is 1 over some number of 9s, followed by an 8, followed by the same number of 0s, followed by a 1.

So, 1/81, 1/9801, 1/998001, 1/99980001, 1/9999800001, etc.

Post reply on HN