#include
using namespace std;
int main() {
int t;
cin>>t;
while(t>0)
{ int num,fact=1;
cin>>num;
while(num>1)
{ fact=fact*num;
num–;
}
cout<<fact<<endl;
t–;
}
return 0;
}
//find the factorial of a number
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t>0)
{ int num,fact=1;
cin>>num;
while(num>1)
{ fact=fact*num;
num–;
}
cout<<fact<<endl;
t–;
}
return 0;
}
//find the factorial of a number
Hi, @deba_yan14 –
An int
can hold values up to slightly more than 2 \cdot 10^9. Your solution wouldn’t work for inputs greater than 12 (for example, 13! > 6 \cdot 10^9). I’m not sure if that’s the problem because you didn’t post a link to the problem description…
Scott
Thanks,
I solved the problem…using boost library in c++