Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions factorial/factorial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<stdio.h>
//to find factorial
void main()
{
long int num,a=1,i;
printf("Enter the no to find the factorial");
scanf("%d",&num);
for(i=1;i<num;num--)
{
a=a*num;
//decrementing value of num(num--;)
}
printf("\n factorial is %d",a);
}
16 changes: 16 additions & 0 deletions factorial/factorial_sum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//sum of seven terms of factorial
#include<stdio.h>
void main()
{
double fact=1,res=0;
int i,n;
printf("To calculate the sum of series 1/1!+2/2! ..till n/n! \n ");
printf("Enter value of n\n");
scanf("%d",&n);
for(i=1;i<8;i++)
{
fact=fact*i;
res+=i/fact;
}
printf("the sum of series 1/1!+2/2! ..till n/n! is %lf",res);
}