Skip to content

Instantly share code, notes, and snippets.

@juanbecerra0
Last active November 20, 2019 01:36
Show Gist options
  • Save juanbecerra0/698b89c1f3d262f0f52cfa2eb93aa420 to your computer and use it in GitHub Desktop.
Save juanbecerra0/698b89c1f3d262f0f52cfa2eb93aa420 to your computer and use it in GitHub Desktop.
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