Interview Question

Systems Engineer Interview Santa Clara, CA

How many trailing zeros are in the number 5! (5 factorial)?

brain teaser

Interview Answer

9 Answers


There are 24 trailing zeros. 100*99*98*97*...*2*1. A simple brain-teaser meant to recognize patters of multiplying successive multiples of ten and five.

Interview Candidate on Mar 5, 2009

5!=120. So there is 1 trailing zero.

Anonymous on May 5, 2009

5!=120. So there is 1 trailing zero.

Anonymous on May 5, 2009

This sounds like one geared not so much towards getting the right answer, but getting to it the right way. If you think a bit and say "one", the interviewer will know you did it the brute-force way, doing the math. You'd get at the answer faster, and probably impress them more, if you think instead how many times a ten will be produced in doing that math, rather than what the actual result of the math will be.

simon waters on May 15, 2009

Sorry, I came back here to find what this BS question was and saw that I mistyped it. How may trailing zeros in (100!) ?

Dave on Feb 16, 2012

This post has been removed.
Please see our Community Guidelines or Terms of Service for more information.


>I never met an academic who was an effective engineer.

Really? Your logic seems to show how ineffective of an engineer you are. If Google hires based on this practice, and Google is the de-facto leader in engineering, then what they are doing is the correct solution.

Anonymous on Nov 13, 2013

Anon on Feb 26, 2014

To generate a zero, we need a (5,2) factor pair. For any given number N, we have at least N/2 number of multiples 2, so the number of zeroes can be determined by the count of numbers that have 5 as a factor (i.e we have more 2s than 5s)

Roughly, we can count N/5 numbers that are multiples of 5, add to that numbers that are multiples of 5^2 (these will have two 5 factors) i.e N/25, add to that numbers that are multiples of 5^3 (these will have three 5 factors) and so on.

For eg:
10! -> 2 multiples of 5 -> 2 zeroes
100! -> 20 multiples of 5 + 4 multiples of 25 -> 24 zeros
500! -> 100 multiples of 5 + 20 multiples of 25 + 4 multiples of 125 -> 124 zeros
1000! -> 200 multiples of 5 + 40 multiples of 25 + 8 multiples of 125 (5^3) + 1 multiple of 625 (5^4) -> 249 zeros

anonymous on Sep 21, 2014

Add Answers or Comments

To comment on this, Sign In or Sign Up.