Prime is a very important concept in scientific calculation, Prime is also called prime number. Prime is the purest number, there is no other element, and the other numbers are multiplied by primes. Therefore, the understanding of good primes, for mathematics and procedures, has important significance.
The title is: Ask 1000! Number 0 at the end of the result
Copy Code code as follows:
1000! = 1x2x3x4x5x...x999x1000
Copy Code code as follows:
public static void Main (string[] args) {
The factorial of/*1000 is astronomical, so it is impossible to calculate and see how many 0*/
* Problem-solving ideas: Two primes 2, 5, multiplied to get 10, we can think, how many groups 2, 5, the end of how many 0 * *
/* Operation Method: Operation 1 to 1000 of all the number, to see each number can be 2 and 5 divisible by several times, and statistics, respectively, the assumption is 2 evenly divided 8 times by 5 Division 12 times, then we can think of 8 groups (2,5), that is 8 0*/
The sum of the number of times divisible by 2
int count2 = 0;
The sum of the number of times divisible by 5
int count5 = 0;
Iterate through all the numbers
for (int number = 1; number <= 1000 number + +) {
int dynmicnumber = number;//A copy of the number used for the division of Numbers
while (dynmicnumber% 2 = 0) {//statistics how many times this number can be divisible by 2, but not separately, but statistically to the global
count2++;
Dynmicnumber/= 2;
}
while (dynmicnumber% 5 = 0) {//statistics how many times this number can be divisible by 2, but not separately, but statistically to the global
count5++;
Dynmicnumber/= 5;
}
}
System.out.println ("The number of end 0 is:" + math.min (Count2, count5));
/* Prime is a very important concept in scientific calculation, can be understood as a very simple meaning, such as: white Paper, Bai Suzhen, elements. Prime is also called prime number, quality can also be understood as pure meaning bar, mass, substance, essence.
* Element and quality is the quality, the quality used to describe people's words, can be understood as: the most basic moral, the most primitive human nature, and so on.
* Prime is the purest number, there is no other component of the number, the other number can be said to be multiplied by prime numbers.
* Therefore, the understanding of good primes, for mathematics and procedures, has important significance. */
}