Created
April 28, 2022 08:22
-
-
Save ayitinya/2a61ede61cf069168ced7b6a112529cd to your computer and use it in GitHub Desktop.
I used an unsigned long long int. In python3, there is no limit to the max int, it depends on what your system memory can take. In C, I ran the code in linux, an unsigned long has a range of 0 to 18446744073709551615.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
unsigned long long int factorial(int n) | |
{ | |
if (n == 0) | |
{ | |
return 1; | |
} | |
else | |
{ | |
return n * factorial(n - 1); | |
} | |
} | |
int main(void) | |
{ | |
int n; | |
printf("Enter a number: "); | |
scanf("%d", &n); | |
printf("%lld\n", factorial(n)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment