This is a creation in Article, where the information may have evolved or changed.
N! How many 0 (go language implementations) are included in the results
Detailed explanation See code comment
Package Mainimport ("FMT") type myInt int32/** statistical factorial n! Number of results in 0 * Method 1: Statistics 5 occurrences of the number of times * 25 appeared two 5* because any one even can and 5 composition 10* and even quantity is sufficient */func fZereCount1 (n myInt) myInt {var count, I myInt = 0, 0/ /full enumeration for; n >= 5; n--{i = n//i value is not equal to 0, so there is no need to add && i > 0for i%5 = = 0 {count++i/= 5}}return count}/** Method 1 The second way */func fzerecount1x ( n myInt) myInt {var i, count, tmp myInt = 1, 0, 0//part enumeration for {if 5*i <= n {count++tmp = i//There may be I value also satisfies the condition for tmp%5 = 0 {Coun T++tmp/= 5}i++} else {return Count}}return count}/** Method 2: Quick Statistics/* For example: 199*count=[199/5]+[199/5/5]+[199/5/5/5]* explanation: [199/5] That is, how many of the 199 can be divisible by 5 (rounding) * [199/5/5] that is, how many of the 199 can be divisible by 25 (rounding) * [199/5/5] that is, how many 199 can be divisible by 125 (rounding) * Special number: 125, can be 5, 25 can also be divisible by 75, so need to be counted 3 times * Summary: This method is essentially the number of statistics 5 */func fZereCount2 (n myInt) myInt {var count, tmp myInt = 0, 0for {tmp = n/5if TM p > 0 {n = tmpcount + tmp} else {return Count}}return count}/** code author: Days of Blog: http://blog.csdn.net/WAPWO?viewmode=content S */func Main () {FMT. Println (FZereCount1 (10000)) FMT. Println (FZERECOUNT1X (10000)) FMT. Println (fZeReCount2 (10000))}