Factorial program in C language using function and loops
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; }