5 kyu
Number of trailing zeros of N!
8,746 of 57,562Ivan Diachenko
Description:
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
N | Product | N factorial | Trailing zeros |
---|---|---|---|
6 |
1*2*3*4*5*6 |
720 |
1 |
12 |
1*2*3*4*5*6*7*8*9*10*11*12 |
479001600 |
2 |
Hint: You're not meant to calculate the factorial. Find another way to find the number of zeros.
Algorithms
Logic
Mathematics
Similar Kata:
Stats:
Created | Feb 9, 2014 |
Published | Feb 9, 2014 |
Warriors Trained | 129543 |
Total Skips | 24419 |
Total Code Submissions | 348237 |
Total Times Completed | 57562 |
CoffeeScript Completions | 147 |
JavaScript Completions | 13372 |
Ruby Completions | 1741 |
Haskell Completions | 1078 |
Clojure Completions | 334 |
Python Completions | 21307 |
Java Completions | 8746 |
C# Completions | 3539 |
Objective-C Completions | 26 |
C++ Completions | 4656 |
C Completions | 2079 |
R Completions | 151 |
NASM Completions | 34 |
Rust Completions | 1216 |
Groovy Completions | 49 |
Scala Completions | 319 |
Prolog Completions | 26 |
F# Completions | 48 |
Crystal Completions | 20 |
COBOL Completions | 14 |
Go Completions | 677 |
Lua Completions | 114 |
Factor Completions | 15 |
Swift Completions | 181 |
D Completions | 16 |
OCaml Completions | 40 |
Julia Completions | 19 |
Total Stars | 2298 |
% of votes with a positive feedback rating | 84% of 4908 |
Total "Very Satisfied" Votes | 3637 |
Total "Somewhat Satisfied" Votes | 933 |
Total "Not Satisfied" Votes | 338 |