Skip to content

Instantly share code, notes, and snippets.

@rohithill
Last active July 8, 2016 03:20
Show Gist options
  • Save rohithill/af1d91d0dadd8ef97908a5f36cee81c8 to your computer and use it in GitHub Desktop.
Save rohithill/af1d91d0dadd8ef97908a5f36cee81c8 to your computer and use it in GitHub Desktop.
Calculating factorial using recursion.
#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
}
@rohithill
Copy link
Author

This is for Turbo C++. Very Old Indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment