recent

sum of factorial series


sum of factorial series
1! + 2! + 3! + 4! + 5! + ... + n!

#include<stdio.h>

long factorial(int n)
{
    long j, facttorial=1;
    for(j=1;j<=n;j++)
    {
        facttorial=facttorial*j;
    }
    return facttorial;
}

int main()
{
    long j,n,sum=0;
    n=5;
    for(j=1;j<=n;j++)
    {
        sum=sum+factorial(j);
    }
    printf("Sum: %d",sum);
}
Powered by Blogger.