Last active
November 20, 2019 01:36
-
-
Save juanbecerra0/698b89c1f3d262f0f52cfa2eb93aa420 to your computer and use it in GitHub Desktop.
This file contains 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
void main() { | |
print(factorial(1)); | |
print(factorial(5)); | |
print(factorial(10)); | |
print(factorial(20)); | |
} | |
int factorial(int n) { | |
if (n <= 1) { // Base case | |
return 1; | |
} else { // Recursive case/call | |
return (n * factorial(n - 1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment