5 kyu
Number of trailing zeros of N!
147 of 57,870Ivan 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 | 130023 |
Total Skips | 24459 |
Total Code Submissions | 349153 |
Total Times Completed | 57870 |
CoffeeScript Completions | 147 |
JavaScript Completions | 13449 |
Ruby Completions | 1742 |
Haskell Completions | 1080 |
Clojure Completions | 334 |
Python Completions | 21427 |
Java Completions | 8787 |
C# Completions | 3558 |
Objective-C Completions | 26 |
C++ Completions | 4679 |
C Completions | 2087 |
R Completions | 152 |
NASM Completions | 34 |
Rust Completions | 1230 |
Groovy Completions | 49 |
Scala Completions | 321 |
Prolog Completions | 26 |
F# Completions | 48 |
Crystal Completions | 20 |
COBOL Completions | 14 |
Go Completions | 686 |
Lua Completions | 119 |
Factor Completions | 15 |
Swift Completions | 188 |
D Completions | 16 |
OCaml Completions | 40 |
Julia Completions | 19 |
Total Stars | 2304 |
% of votes with a positive feedback rating | 84% of 4925 |
Total "Very Satisfied" Votes | 3649 |
Total "Somewhat Satisfied" Votes | 937 |
Total "Not Satisfied" Votes | 339 |