A program to display the following series:

      1, 2/2!, 3/3!, 4/4!, ........., n/n!

where n is a number inputted by the user.

 

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
double i,j,n,denominator;

cout<<"Enter the limit of the numerator: ";
cin>>n;

cout<<"\nSeries: ";
for(i=1;i<=n;i++)
{
denominator=1;

for(j=1;j<=i;j++)
denominator=denominator*j;

cout<<i/denominator<<" ";
}

getch();
}

 

< Back