#21 Number of trailing zeros of N!
Write a program that will calculate the number of trailing zeros in a factorial of a given number.
N! = 1 * 2 * 3 * ... * N
Be careful 1000! has 2568 digits...
For more info, see: http://mathworld.wolfram.com/Factorial.html
Examples
zeros(6) = 1
# 6! = 1 * 2 * 3 * 4 * 5 * 6 = 720 --> 1 trailing zero
zeros(12) = 2
# 12! = 479001600 --> 2 trailing zeros
Hint: You're not meant to calculate the factorial. Find another way to find the number of zeros.
팩토리얼을 구하고 0의 갯수를 세면... 타임 초과가 난다 이틀 연속 타임 초과
'매일매일개발 > Codewars' 카테고리의 다른 글
codewars #23 Prime Streaming (NC-17) (2kyu) (1) | 2018.04.17 |
---|---|
codewars #22 Fat Fingers (5kyu) (0) | 2018.04.16 |
codewars #20 The Millionth Fibonacci Kata (3kyu) (0) | 2018.04.12 |
codewars #19 The Clockwise Spiral (5kyu) (0) | 2018.04.11 |
codewars #18 Convert string to camel case (5kyu) (1) | 2018.04.10 |