20! = 20 x 19 x 18 x 17 x 16 x 15 x 14 x 13 x 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 2432902008176640000
20! = 20 x 19 x 18 x 17 x 16 x 15 x 14 x 13 x 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 2432902008176640000
The number of different peptides that can be formed by using all 20 standard amino acids exactly once is 20 factorial, denoted as 20!. This calculates to approximately 2.43 x 10^18 unique peptides. Each peptide in this collection would have a distinct sequence of the 20 amino acids arranged in a specific order.
The factorial of 0 is indeed 1, but that's not really a problem. The problem is that the factorial of 20 is 2,432,902,008,176,640,000 and that's the largest factorial that will fit in a 64-bit integer. With only 21 factorials (including 0) to play with, a simple lookup table would be a lot quicker than calculating each of them separately. unsigned __int64 factorial(unsigned num) { switch (num) { case (0): case (1): return 1; case (2): return 2; case (3): return 6; case (4): return 24; case (5): return 120; //.... case (20): return 2432902008176640000; } return 0; // indicates error! } To calculate them individually, use the following function: unsigned __int64 factorial (unsigned num) { if (20<num) return 0; // indicates error! unsigned __int64 result= 1; while (1<num) result *= num--; return result; } To accommodate factorials greater than 20 you could use a 64-bit double-precision float, however the results will be an approximation rather than precise and the risk of overflowing still exists. The best solution is to employ a user-defined, dynamically-sized type specifically designed to cater for large integrals (although they'd no longer be integral, of course). There are many libraries available to cater for this but, personally, I use the GMP library as it's one of the fastest available.