Skip to content

Instantly share code, notes, and snippets.

@bakhbk
Last active March 23, 2022 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakhbk/f5774da5ce9ca3f5e2719ce1d29a348e to your computer and use it in GitHub Desktop.
Save bakhbk/f5774da5ce9ca3f5e2719ce1d29a348e to your computer and use it in GitHub Desktop.
void main() {
print(fact(5)); // 120
}
int fact(int x) {
if (x == 1) {
return 1;
} else {
return x * fact(x - 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment