Program to find the nth terms of its factorial(Level - Medium)

Program # 22: Program to find out nth factorial of given number

//Program to find the nth terms of its factorial(Level - Medium)
#include <iostream.h> 
#include <conio.h>

void main()
{
int i,n;
float long res,j,z; 
clrscr ();
cout<<"Enter any number you want to series = "; 
cin >> n;
res = 1;
z = 0;

for (i=1;i<=n;i++)
{
res = res*i; j = i/res;
z = z+j;
}

cout<<"1/1! + 2/2! + 3/3! + 4/4! +..... +n/n! = "<<z;
getch ();
}


Post a Comment

0 Comments