1020
N = ----------------------
999999999989999999999
Find the 250th digit to the right of the decimal point.
Computer program essentially reproduces the results of long division, provided that the divisor and dividend are integers.
Program output (40 dec places per line):
0.1000000000010000000001100000000021000000
0013100000000341000000016510000000506100
0000215710000007218100000287891000010097
0100003888611000139856210005287173100192
7279410072144525102648724661098631771713
6350423782349821954959848643331948308388
2793317272
The 250th digit to the right of the decimal point is 2
----------
def large_divide_prec(divisor,dividend,prec=100):
""" divisor & dividend must be integers """
dsr = divisor
dnd = dividend
whole_part = dnd//dsr
dnd = dnd - whole_part*dsr
ans = str(whole_part)
# dsr is now greater than dnd
quot = ''
dnd *= 10
for iter in range(prec):
if dsr > dnd:
quot += '0'
dnd *= 10
else:
quot += str(dnd // dsr)
dnd = (dnd % dsr)*10
return ans + '.' + quot
print(large_divide_prec(999999999989999999999,10**20, 250))
print('The 250th digit to the right of the decimal point is',
large_divide_prec(999999999989999999999,10**20, 250)[-1])
|
Posted by Larry
on 2025-02-09 11:18:08 |