small factorials..why am i getting wrong answer for my code..? my code is only working for small numbers not for the large ones ..plzz help me out

int main()
unsigned long f=1;
int t,i,j;
int n[t];

return 0;


the answer that you are calculating is out of range of int,long long and unsigned long long …

Instead of reading the editorial, I would suggest you to think on your own.
Here are couple of hints :

  1. Your code is giving WA because you are overshooting the range of long long int.
  2. Think how you can store integers with more than 18/19 digits, since no predefined data type in C/C++ can store it.
  3. Also think how can you add/multiply such large numbers.

Think of arrays and strings. Good Luck!

Remember the sizes if these data types in c+±>

signed char: -127 to 127 (note, not -128 to 127; this accommodates 1’s-complement platforms)
unsigned char: 0 to 255
char: -127 to 127 or 0 to 255 (depends on default char signedness)
short: 10^5
unsigned short: 10^5
int: 10^5
unsigned int: 0 to 10^5
long: 10^10
unsigned long: 0 to 10^10
long long: 10^18
unsigned long long: 0 to 10^19

Now about your wrong answer->
You are getting wrong answer because you are trying to store that value which is larger than 10^19 and 100! factorial has around 150 digits, so the solution is to use the array to store each digit.

If you are facing problem in implementing the code, comment below and I will give you the code.

so… what should i do??? plzzz help…

As the answer is very large,you need to store the number in array(one digit at one index of array )… I suggest you to read this tutorial