N = 1234.........78798081
Determine the remainder and the last four digits of the quotient when N is divided by 2023.
The last four digits are 5846
The remainder is 1623
61026588779590771831518397524479101494934566130959
12666008083854366752552764925628509564757860867748
6731382086315503532657774033468696360591086395846
with remainder 1623
---------------
def large_divide(divisor, dividend):
if type(dividend) == str:
dividend = [int(i) for i in dividend]
elif type(dividend) == int:
dividend = [int(i) for i in str(dividend)]
quotient = []
tempdividend = 0
i=0
for i,v in enumerate(dividend):
tempdividend = tempdividend*10 + dividend[i]
quotient.append(tempdividend // divisor)
tempdividend = tempdividend % divisor
wholepart = ''.join([str(j) for j in quotient])
remainder = tempdividend
ans = wholepart.lstrip('0')+'\nwith remainder '+ str(remainder)
return ans
strN = ''.join([str(i) for i in range(1,82)])
print(large_divide(2023, strN))
|
Posted by Larry
on 2023-09-24 07:56:25 |