#include<bits/stdc++.h>
using namespace std;
//int ar[]={1,2,3,4,5},sum;
//int x;
int n;
int f(int i,int x)
{
//int i=1;
//cout<<i<<" "<<x<<endl;
//x+=i;
if(i==n)
return x*i;
return x=f(i+1,x*i);
}
int main()
{
while(cin>>n)
{
cout<<f(1,1)<<endl;
}
}
using namespace std;
//int ar[]={1,2,3,4,5},sum;
//int x;
int n;
int f(int i,int x)
{
//int i=1;
//cout<<i<<" "<<x<<endl;
//x+=i;
if(i==n)
return x*i;
return x=f(i+1,x*i);
}
int main()
{
while(cin>>n)
{
cout<<f(1,1)<<endl;
}
}
Another code:
#include<bits/stdc++.h>
using namespace std;
//int ar[]={1,2,3,4,5},sum;
//int x;
int n;
int f(int i)
{
//int i=1;
//cout<<i<<" "<<x<<endl;
//x+=i;
if(i==0)
return 1;
return i*f(i-1);
}
int main()
{
while(cin>>n)
{
cout<<f(n)<<endl;
}
}
#include<bits/stdc++.h>
using namespace std;
//int ar[]={1,2,3,4,5},sum;
//int x;
int n;
int f(int i)
{
//int i=1;
//cout<<i<<" "<<x<<endl;
//x+=i;
if(i==0)
return 1;
return i*f(i-1);
}
int main()
{
while(cin>>n)
{
cout<<f(n)<<endl;
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন