Last active
July 8, 2016 03:20
-
-
Save rohithill/af1d91d0dadd8ef97908a5f36cee81c8 to your computer and use it in GitHub Desktop.
Calculating factorial using recursion.
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
#include <iostream.h> | |
#include <conio.h> | |
long factorial(int n) | |
{ | |
if(n==0) | |
return 1; | |
else | |
return n * factorial(n-1); | |
} | |
void main() | |
{ | |
cout<<factorial(5); | |
getch(); //To pause program in some compilers | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is for Turbo C++. Very Old Indeed.