Created
October 22, 2012 18:53
-
-
Save felipernb/3933368 to your computer and use it in GitHub Desktop.
Factorial in C
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
long recurFact(int n) { | |
if (n == 0) return 1L; | |
return n * recurFact(n-1); | |
} | |
long iterFact(int n) { | |
long fact = 1; | |
for (; n > 1; n--) fact *= n; | |
return fact; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment