NEED YOUR HELP!
Hello there everyone. I am trying to solve this problem but I am getting the wrong answer
APPROACH - Natural Log Factorial Algorithm
Here is my code, for which I have checked factorial of 1,100,51,27… and it was correct output but when I submit solution I am getting the Wrong Answer can anyone please suggest me what I am doing wrong
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
void gogo(){
int n;
cin >> n;
if(n==1){
cout << 1 << endl;
return;
}
long double s=0;
for(int i = 1 ; i <= n ; i++)
s += log(i);
string r = to_string(round(exp(s)));
for(int i = 0 ; i < r.length() ; i++){
if(r[i] == '.')
break;
else
cout<<r[i];
}
cout<<endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T;
cin >> T;
while (T--) {
gogo();
}
return 0;
}