New Want to Write for Computaholics ? if Yes Contact us at "contact@computaholics.in"

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);
}
Copyright © C Program | Java | OpenGL Programming | Hadoop at Computaholics