Click here to Skip to main content
13,591,625 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


Posted 3 Oct 2011
Licenced CPOL

Calculate the Factorial of an Integer in C#

, 3 Oct 2011
Rate this:
Please Sign up or sign in to vote.
Use factorial(int n){ if(n<0) return -1; if(n==0 || n==1) return 1; return n * factorial(n-1);}
Use Recursion.
int factorial(int n)
  return -1;
 if(n==0 || n==1)
  return 1;

 return n * factorial(n-1);


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


About the Author

Anshul R
India India
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralReason for my vote of 5 good Pin
mandar130519-Oct-11 0:25
membermandar130519-Oct-11 0:25 
GeneralGuys, please. This is a tail-recursion and it won't be any s... Pin
ckbz18-Oct-11 21:13
memberckbz18-Oct-11 21:13 
GeneralReason for my vote of 1 Besides, recursion for the sake of r... Pin
victorbos18-Oct-11 3:23
membervictorbos18-Oct-11 3:23 
GeneralReason for my vote of 1 The time has long since passed when ... Pin
Chris Maunder4-Oct-11 2:47
adminChris Maunder4-Oct-11 2:47 
GeneralA standard and simple solution, my 5. However, the original ... Pin
Edward Nutting3-Oct-11 20:24
memberEdward Nutting3-Oct-11 20:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.180618.1 | Last Updated 3 Oct 2011
Article Copyright 2011 by Anshul R
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid