Click here to Skip to main content
15,888,816 members
Articles / Programming Languages / C#

Calculate the Factorial of an Integer in C#

Rate me:
Please Sign up or sign in to vote.
2.25/5 (6 votes)
3 Oct 2011CPOL 17.2K  
Use Recursion.int factorial(int n){ if(n<0) return -1; if(n==0 || n==1) return 1; return n * factorial(n-1);}

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions