Created
November 24, 2013 21:39
-
-
Save montyr75/7632735 to your computer and use it in GitHub Desktop.
Dart factorial function.
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
int factorial(int number) { | |
int factorialRange(int bottom, int top) { | |
if (top == bottom) { | |
return bottom; | |
} | |
return top * factorialRange(bottom, top - 1); | |
} | |
return factorialRange(1, number); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment