Live data from Hacker News

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

iheartchaos.com

1–10 of 99 posts

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

#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

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

#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?

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

#8
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).

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

#9
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?

[deleted]
Post reply on HN