Search C Program

Series Program 4


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

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);
    return 0;
}


Related Links:
- More Series Programs
- Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C

2 comments:

  1. It is giving me the wrong value

    ReplyDelete
    Replies
    1. whats your input and expected output ?

      Delete