I\'ve been trying to make a factorial function in C++, and I just found that inputs which are greater than 10 are not calculated correctly. I tried C# but I faced the same probl
Variables cannot hold an infinite number of values. On a 32-bit machine, the maximum value an int can represent is 2^31-1, or 2147483647. You can use another type, such as unsigned int, long, unsigned long, long long, or the largest one, unsigned long long. Factorials are big numbers, and can easily overflow! If you want arbitrary precision, you should use a bignum library, such as GNU GMP.