A. 1000! How many digits are there? Why?
First go to the Code to see at a glance
int n = 1000; double sum = 0; for (int i = 1; i <= n; i++) { sum = sum + Math.Log10(i); } Console.WriteLine("The '1000! has %{0}'s numbers.\n", (int)sum + 1);
Principles
For example: 1234 = 1.234*10 ^ 3
By referencing the logarithm, you can simply obtain the number of digits.
Log10 (a * 10 ^ x) = log10 (a) + x
Calculate 1000 again! Number of results
Log10 (1000 !) = Log10 (1000*999 *... 2*1) = log10 (1000) + log (999) +... + Log (1)
B. 1000! Specific value
2586 this is a huge number, which is obtained by countless computations in general.
You must use the multiplication of large numbers to complete the calculation.
The specific idea is to convert a number into a string and then perform multiplication on the string to obtain the result.
See: http://wenku.baidu.com/view/5623fcc14028915f804dc218.html for code
1000! A total of 2586 digits, as shown in the figure. That's pretty spectacular! |
|
External Link
- Factorial http://baike.baidu.com/view/245476.htm.
- Logarithm http://baike.baidu.com/view/356.htm