Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Non-recursive version
- int Factorial(int iBase)
- {
- int iAnswer = iBase;
- for(int i = iBase-1; i > 0; i--)
- {
- iAnswer = iAnswer * i;
- }
- return iAnswer;
- }
- /*
- //Recursive version
- int Factorial(int iBase)
- {
- if(iBase == 1)
- {
- return iBase;
- }
- else
- {
- return iBase * Factorial(iBase-1);
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement