Factorial program in C language

Spread the love

Factorial program in C language using function and loops

Number Series program

 

In this program, we will see the Factorial program in C language using function and loops. Please look into the program.

1! + 2! + 3! + 4! + 5! + ... + n!

The C program for the Number Series program is as follows:

#include <stdio.h>

long fact(int n)
{
    long i, f=1;
 
    for(i=1;i<=n;i++)
    {
        f=f*i;
    }
    return f;
}

int main()
{
    long i,n,sum=0;
    n=5;
 
    for(i=1;i<=n;i++)
    {
        sum=sum+fact(i);
    }
    
 printf("Sum: %d",sum);
    getch();
 return 0;
}

Number Series Programs in C programmming

Star Pattern Programs in C programmming

Number Pattern Programs in C programmming

Alphabet Pattern Programs in C programmming


Spread the love

Leave a Comment