#include<iostream.h>
int main()
{
int i,n,j,fa=1,sq=1;
float ans=0.0,sum=0.0;
cout<<"Enter any number : ";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
fa=fa*j;
sq=sq*i;
}
ans=(float)sq/(float)fa;
if(i%2!=0)
sum+=ans;
else
sum-=ans;
fa=1;
sq=1;
}
cout<<sum;
}
No comments:
Post a Comment