Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,938 questions

51,875 answers

573 users

How to recursively calculate factorial of a number with large result in Python

1 Answer

0 votes
def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n - 1)

print(factorial(500))

 
'''
run:
  
1220136825991110068701238785423046926253574342803192842192413588385
8453731538819976054964475022032818630136164771482035841633787220781
7720048078520515932928547790757193933060377296085908627042917454788
2424912726344305670173270769461062802310452644218878789465754777149
8634943677810376442740338273653974713864778784954384895955375379904
2324106127132698432774571554630997720278101456108118837370953101635
6324432987029563896628911658974769572087926928871281780070265174507
7684107196243903943225364226052349458501299185715012487069615681416
2535905669342381300885624924689156412677565448188650659384795177536
0894005745238940335798476363944905313062323749066445048824665075946
7358620746379251842004593696929810222639719525971909452178233317569
3458150855233282076282002340262690789834245171200620771464097945611
6127629145951237229913340169552363850942885592018727433795173014586
3575708283557801587354327688886801203998823847021514676054454076635
3598417443048012893831389688163948746965881750450692636533817505547
8128640000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000
  
'''

 



answered Jun 24, 2018 by avibootz
edited Jun 24, 2018 by avibootz

Related questions

1 answer 148 views
1 answer 172 views
1 answer 91 views
2 answers 226 views
1 answer 155 views
1 answer 52 views
...