Print The Pattern | 1 + 2! / 2 + 3! / 3 + ... | User given limit | C-Program
Print the following pattern :
1 + 2! / 2 + 3! / 3 + 4! / 4 + 5! / 5 + 6! / 6 + . . . . .
Tips:
1.Use nested loop.2.Add factorial in series.
3.Then, divide each factorial by initial value taken from first loop.
Code:
#include<stdio.h>
void main()
{
int x,i,j,a,b=0;
printf("Enter the range:\n");
scanf("%d",&x);
for(i=1;i<=x;i++)
{
if(x!=i)
printf("%d!/%d +",i,i);
else
printf("%d!/%d =",i,i);
a=1;
for(j=1;j<=i;j++)
a=(a*j);
a=a/i;
b=b+a;
}
printf("%d",b);
}
WOW....wow sir
ReplyDeleteGreat sir, such a wonderful program, i would like to see this type of pattern printing program in future.
ReplyDeleteWow sir
ReplyDelete