## INDEX

### FIND FACTORIAL OF A NUMBER USING RECURSION IN C PROGRAM

1. Factorial program by recursion in c

2. Factorial program in c using recursion

3. C program to calculate factorial using recursion

4. Recursive function for factorial in c

#include<stdio.h>
int fact(int);
int main(){
int num,f;
printf("\nEnter a number: ");
scanf("%d",&num);
f=fact(num);
printf("\nFactorial of %d is: %d",num,f);
return 0;
}

int fact(int n){
if(n==1)
return 1;
else
return(n*fact(n-1));
}

Sum of n numbers using recursion in c
Matrix multiplication using recursion in c
Multiplication using recursion in c
Lcm using recursion in c
Using recursion in c find the largest element in an array
Prime number program in c using recursion
Decimal to binary conversion in c using recursion
C program for fibonacci series using recursion
Reverse a string using recursion
Write a program for palindrome using recursion
Find factorial of a number using recursion in c program
Find gcd of a number using recursion in c program
Find sum of digits of a number using recursion using cprogram
Find power of a number using recursion using c program
Binary search through recurssion using c program
Reverse a number using recursion in c program
Big list of c program examples

1. i am gopi ,i executed ur code and got the out put
really it is simple code and understandable

2. er 500.. it'll go out of stack..
segmentaton fault... worst code!!

3. factorial of 500 is too large number which is the beyond the range of int, long int..

4. this is too simple...

I did it in 7th

try factorial of no.s up to 500

1. u might be scientist now. . . :p

2. no you did not

5. Mahesh Mudithenapalli7/10/10, 11:51 PM

Plz write code for getting factorial for large numbers like 100..

6. Hi Mahesh Mudithenapalli,
Plz write code for getting factorial for large numbers like 100..
This code can calculate factorial of numbers more than 200
Note: Increase the value of MAX for more larger numbers.

#include"stdio.h"
#define MAX 1000
void factorialof(int);
void multiply(int);
int length = 0;
int fact[MAX];

int main(){
int num;
int i;

printf("Enter any integer number : ");
scanf("%d",&num);

fact[0]=1;

factorialof(num);

printf("Factorial is : ");
for(i=length;i>=0;i--){
printf("%d",fact[i]);
}

return 0;
}
void factorialof(int num){
int i;
for(i=2;i<=num;i++){
multiply(i);
}
}
void multiply(int num){
long i,r=0;
int arr[MAX];
for(i=0;i<=length;i++){
arr[i]=fact[i];
}

for(i=0;i<=length;i++){
fact[i] = (arr[i]*num + r)%10;
r = (arr[i]*num + r)/10;
//printf("%d ",r);
}
if(r!=0){
while(r!=0){
fact[i]=r%10;
r= r/10;
i++;
}
}
length = i-1;
}

Example:
100! = 93326215443944152681699238856266700490715968264381
62146859296389521759999322991560894146397615651828
62536979208272237582511852109168640000000000000000
00000000

1. This isn't recursion anymore

7. great..................

8. what if we entered 0?

:D

9. Factorial of zero is one.

10. hi i m sandeep. i want to print the elephant for e.so, plz tell me

11. plz tell me about my question

12. hi i m sandeep . i m doing mca

13. what is the program to find out the sum of 1!+2!+3!+......................+n!
where(n<=0)

14. i didnt get the logic of this program!!! according to the above program, the value of n will go on decreasing and atlast become 1... but when n=1, the program should return 1..(?)i am a mere beginner... please "enlighten" me... why is it printing value of "return(n*fact(n-1))" and not "return(1)"???

15. @ anonymous plz read dis part of the code

if(n==1)
return 1;
i think it answers ur question

16. x/1! - x3/3! + x5/5! not use pow() in x,x3......

17. This comment has been removed by the author.

18. #include
main()
{
int i,n,f=1; /*n is the number of which fact. is to be calculated*/
printf("enter the number");
scanf("%d",&n);
for (i=1;i<=n;i++)
{
f=f*i;
}
printf("the factorial of the number is %d",n);
}

19. There is no prototype declaration in the program N u have used the fact() in the body of the program. Sweety.Mca 1st sem.KIIT.Bhubneshwar.

20. If return type of any function is int then declaration of prototype of function is optional.

21. well thats great but they will be error you have error prototype

22. hey there us one mistake in your program before return 0;
use getch();
also because when we enter the number and press enter then it is going back to the command mode

23. can someone use only and list container to perform a list of prime number? without using for, do and while loop....anyone?

24. #include
#include
voidmain()
{
int i,num,fact=1;
clrscr();
printf("accept a num");
scanf("%d",&num);
for(i=1;i<=num:i++)
{
fact=fact*i;
}
printf("fact=%d",fact);
getch();
}

25. hello! i have a question regarding to what happens when the statement is "return(n*fact(n-1));"
like what is it that d return function do ...... does it go through a repeated process or smthing like that
?

26. how to create a functin which returns power? plz lemme know asap......

27. how can b gentrate the output of factorial of a number by using only for loop??? like when we enter 4 the output will b 24.

28. Nice program admin you website is awesome for new programmers.

29. are bhai factorial ka program galat hai upar jaha n==1 hai waha n==0 hoga ok sahi karle usko

30. :)

31. thanks alot

32. good

33. /*#include*/
#include
#include
#include
int fact(int n)
{
if(n==1||n==0)
return 1;
else
return(n*fact(n-1));
}

void main()
{
int n,i;
FILE *fp;
clrscr();
fp=fopen("factorial.txt","w+");
scanf("%d",&n);

fprintf(fp,"\noutput of fact====%d",fact(n));
fclose(fp);
getch();
}

/* please see my program factorial with file..............

34. i need "write a c program to find sum of 1!+2!+3!...n!"

35. thank u ritesh kumar ur programs always help me a lot during these college days. thank u once again

36. your code is didn't clear but this code is easy to under stand
#include
using namespace std;
int fuct(int);
int main()
{
int n;
cout<<"enter the number of fuctorial=";
cin>>n;
fuct(n);
return 0;
}
int fuct(int x)
{
if(x==0)
return 1;
else
return x*fuct(x-1);
}

37. plzzz..i want oop conseptconsept..

38. sum=11+21+31+...+m1 use factorial in c++programming