Write a C program which will calculate the factorial
Program code
Write a C program which will calculate the factorial of the first 25 numbers
#include<stdio.h>
long factorial (long number);
int main()
{
int a;
for(a=0;a<=25;a++){
printf("%7d=%10d\n",a,factorial(a));
}
return 0;
}
long factorial (long number)
{
if (number<=1){
return 1;
}
else{
return(number*factorial(number-1));
}
}
Input
Write a C program which will calculate the factorial of the first 25 numbers
#include<stdio.h>
long factorial (long number);
int main()
{
int a;
for(a=0;a<=25;a++){
printf("%7d=%10d\n",a,factorial(a));
}
return 0;
}
long factorial (long number)
{
if (number<=1){
return 1;
}
else{
return(number*factorial(number-1));
}
}
Input
Output
No comments