# What's wrong with this code? getting wrong answer while submitting plz smone hlp

#include<stdio.h>

int main(void) {
int T,i;
scanf("%d",&T);
for(i=1;i<=T;i++){
int a,fact=1;
scanf("%d",&a);

``````       while(a>1){

fact=fact*a;
a=a-1;
}

printf("%d\n",fact);
}
return 0;
``````

}

Since you have used int data type for fact, answer might have been overflowed, better try by declaring fact as long long.

tried that but its still saying wrong answer

Even long long int data type cant store the value of fact(100)=933262154439441526816992388562667004-
907159682643816214685929638952175999-
932299156089414639761565182862536979-
208272237582511852109168640000000000-
00000000000000, better try this `

How to compute factorial of 100 using a C/C++ program?

Find the Factorial of a large number - GeeksforGeeks

Use Big int available in java and python to compute factorial

def fact(n):
if(n==0 or n==1):
return 1
else:
return n*fact(n-1)
q=int(input())
for _ in range(q):
n=int(input())
print(fact(n))

`

You Can Checkout My Answer Try To Understand The Concept And Write It In C++
Or Check Out Is Editorial

``````import java.io.BufferedReader;
import java.io.IOException;
import java.math.BigInteger;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{