Live data from Hacker News

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

iheartchaos.com

11–20 of 99 posts

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

#12
post #4

This can be seen in python with (I had to dig into the docs for this, so here are the fruits of my labor :) ) import decimal decimal.getcontext().prec=1000 dec = decimal.Decimal(1)/decimal.Decimal(998001) #now doctor it up to see the numbers strdec = str(dec)[2:] #chop off the '0.' nums = zip(strdec[::3],strdec[1::3],strdec[2::3]) print nums

You've got an extra ) on the 'nums = .....'

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

#13
post #6
post #4

This can be seen in python with (I had to dig into the docs for this, so here are the fruits of my labor :) ) import decimal decimal.getcontext().prec=1000 dec = decimal.Decimal(1)/decimal.Decimal(998001) #now doctor it up to see the numbers strdec = str(dec)[2:] #chop off the '0.' nums = zip(strdec[::3],strdec[1::3],strdec[2::3]) print nums

I don't have a python shell available... what happens after 999?

It repeats.

EDIT: Um... I answered the good man's question. Could someone explain why this correct answer was voted down so I may improve it? I recognize that it is short, but that's really all there is too it. It's a decimal expansion, not a border collie.

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

#16
post #4

This can be seen in python with (I had to dig into the docs for this, so here are the fruits of my labor :) ) import decimal decimal.getcontext().prec=1000 dec = decimal.Decimal(1)/decimal.Decimal(998001) #now doctor it up to see the numbers strdec = str(dec)[2:] #chop off the '0.' nums = zip(strdec[::3],strdec[1::3],strdec[2::3]) print nums

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)

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

#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...
Post reply on HN