研发埠

标题: [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 14:11
标题: [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
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!.




欢迎光临 研发埠 (http://bbs.yanfabu.com/) Powered by Discuz! X3.2