Interview Question
Systems Engineer Interview
-
GoogleHow many trailing zeros are in the number 5! (5 factorial)?
Interview Answers
8 Answers
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
http://www.purplemath.com/modules/factzero.htm
Anon on
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
5 x 4 x 3 x 2 x 1 Simply look how many 10s you can get out of it. In this case 5x2=10 Therefore, only one 10, hence, one trailing zero.
Leo on
5x4x3x2x1 = 120 one Zero
manoj on
>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
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
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.
Anonymous on