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);
} 
Output:


Comments

  1. WOW....wow sir

    ReplyDelete
  2. Great sir, such a wonderful program, i would like to see this type of pattern printing program in future.

    ReplyDelete

Post a Comment

Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)

Popular posts from this blog

TOP 10 PROGRAMMING LANGAUAGES COMMING 2021 | ARTICLE

Write a C-program to swap two number:

Print Fibonacci Series using Recursion | C program :