Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. //Non-recursive version
  2. int Factorial(int iBase)
  3. {
  4. int iAnswer = iBase;
  5. for(int i = iBase-1; i > 0; i--)
  6. {
  7. iAnswer = iAnswer * i;
  8. }
  9.  
  10. return iAnswer;
  11. }
  12. /*
  13. //Recursive version
  14. int Factorial(int iBase)
  15. {
  16. if(iBase == 1)
  17. {
  18. return iBase;
  19. }
  20. else
  21. {
  22. return iBase * Factorial(iBase-1);
  23. }
  24. }
  25. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement