Venkat
Feb 27, 2022

It takes under a millisecond with modern laptops.

from sympy import factorial

from datetime import datetime

t0 = datetime.now()

n = 69

R = factorial(n)

t1 = datetime.now()

with open('69f.txt','w') as f:

f.write(str(R))

f.close()

print ('time = %.2f mu-s' % (t1-t0).microseconds)

Output:

time = 976.00 mu-s

69! = 171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000

How do we know that's the right answer? We can verify the number of zeros - to get a zero we need 2 * 5 which are the prime factors of 10. And since 5 appears five times less often than 2, we need to count how many 5's , 25's, 125's , 625's etc are in 69!. So

int-floor(69/5) + int-floor(69/25) = 15 the number of zeros - checks out.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Responses (1)

Write a response