宋倩倩 发表于 2013-7-30 14:11:28

[google面试题]Without
 using
 a
 calculator,
how
 many
 zeros
 a re
at
 the
end
 of
\"100!\"?

(that\'s
 100*99*98*...*3*2*1)

淡写轻描 发表于 2013-7-30 15:08:44

Answer:What you don't want to do is start multiplying it all out!The trick isremembering that the number of zero sat the end of a number is equal to thenumber of times "10" (or "2*5" )appears when you factor the number.Thereforethink about the prime factorization of 100! and how many 2s and 5s there are.There are a bunch more 2s than 5s,so the number of 5s is also the number of 10s in the factorization.There is one 5 for every factor of 5 in our factorial multiplication(1*2*...*5*...*10*...*15*...) and an extra 5 for 25,50,75,and 100.Therefore we have 20+4=24 zero sat the end of 100!.
页: [1]
查看完整版本: [google面试题]Without
 using
 a
 calculator,
how
 many
 zeros
 a re
at
 the
end
 of
\"100!\"?

(that\'s
 100*99*98*...*3*2*1)