Correct output in CMD but wrong answer in codechef.. help please :'(

#include <stdio.h>

using namespace std;

int main(){

int f, t, n;
int another;
vector <int> myVect;
int i=0;
int temp;

for (i=0; i<n; i +=1)

for (int q=0; q<n; q++){

f =;

another = 1;
int t = f;

for (t; t>0; t += (-1)){

	another = another * t;


	return 0;


hey @aalok_sathe

Try running your code for input


Your code Cannot handle this case as

Constraints are:

An integer t, 1<=t<=100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1<=n<=100.

So that mean your code should be able to calculate maximum of 100 factorial and factorial of 100 is


which cannot be stored in integer or floating point datatypes in c or c++, So you have to use array to store the number.

Now how to do that ?

For this problem check this link:

That’s the reason of getting WA.
Hope you understood…! :slight_smile:

Above Answer is absolutely correct.I just want to add one more thing,You can calculate 100! using BiGInteger class in java.So its your choice,you can go either way.My suggestion is that go with @rishabhprsd7 bhaiya…You will learn a lot if you do it that way…