3 ms·
There's no 998 (and it's not a rounding issue)! ... 995 996 997 999
by onedognight 15y ago
There's no 998 (and it's not a rounding issue)!
... 995 996 997 999
- tspiteri 15y agoAnd even the suggested 1/9801 for two digits produces no 98 ... 95 96 97 99 00 01 02 ... And extrapolating it to one digit, 1/81 gives 0.012345679012345679...
- joejohnson 15y agoAgain, the 100 overflows to the 99. This makes the 99 a 100 and then that overflows again and the 98 turns to a 99.
- jeffcapeshop 15y agoyou could always do 1/99980001 - that would have a 0998
- hammock 15y agoBut it would lack a 9998.
- jeffcapeshop 15y agothen i suppose we need 1/9999800001 !
- jQueryIsAwesome 15y agoBut it would lack... just kidding. Another way to get the real consecutive numbers is to make a rest so we avoid that annoying increment at the end: 1/998001 - 1e-1000
- onedognight 15y agoIt's because the 1000 will end up adding one to the 999 which becomes 1000 which adds one to 998.
- kghose 15y agoYes, 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)