Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int facto(int n)
- {
- if(n == 0)
- {
- return 1;
- }
- else if(n == 1)
- {
- return 1;
- }
- else
- {
- return n * facto(n-1);
- }
- }
- int main()
- {
- int n,ans;
- printf("Enter the number to find factorial: ");
- scanf("%d",&n);
- ans = facto(n);
- printf("%d ! = %d",n,ans);
- getch();
- return(0);
- }
Add Comment
Please, Sign In to add comment