Determine the value of:
{(2021)!/(2017)2}
Where, {x} = x - ⌊x⌋
Note: ⌊x⌋ denotes the floor function - that is, the greatest integer less than or equal to x.
*** Computer program assisted solutions are welcome, but an analytic solution is preferred.
For me, a straightforward calculation leads to a computer overflow error.
I used an algorithm that repeatedly subtracts (10^n)*2017^2 where n is the most zeros you can concatenate without making the number to be subtracted too large.
Once the numerator is small enough, then a simple division shows the result.
The final numerator was 4019881 which is 1993*2017
The solution to the problem is 0.9881011403073872 which is 1993/2017
-----------
def fac(n):
""" Factorial """
if n == 1 or n == 0:
return 1
else:
return n*fac(n-1)
bigfac = fac(2021)
numerator = bigfac
while numerator > 4068289:
snumer = str(numerator)
length = len(snumer)
start = int(snumer[:7])
if start < 4068289:
subtract = int('4068289' + '0'*(len(snumer)-8) )
elif start >= 4068289:
subtract = int('4068289' + '0'*(len(snumer)-7) )
numerator -= subtract
print(numerator)
print(numerator/4068289)
Edited on March 25, 2023, 3:24 pm
|
Posted by Larry
on 2023-03-25 15:21:11 |