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

Stats:

CreatedFeb 9, 2014
PublishedFeb 9, 2014
Warriors Trained130023
Total Skips24459
Total Code Submissions349153
Total Times Completed57870
CoffeeScript Completions147
JavaScript Completions13449
Ruby Completions1742
Haskell Completions1080
Clojure Completions334
Python Completions21427
Java Completions8787
C# Completions3558
Objective-C Completions26
C++ Completions4679
C Completions2087
R Completions152
NASM Completions34
Rust Completions1230
Groovy Completions49
Scala Completions321
Prolog Completions26
F# Completions48
Crystal Completions20
COBOL Completions14
Go Completions686
Lua Completions119
Factor Completions15
Swift Completions188
D Completions16
OCaml Completions40
Julia Completions19
Total Stars2304
% of votes with a positive feedback rating84% of 4925
Total "Very Satisfied" Votes3649
Total "Somewhat Satisfied" Votes937
Total "Not Satisfied" Votes339
Ad
Contributors
  • Ivan Diachenko Avatar
  • jhoffner Avatar
  • xcthulhu Avatar
  • vertighel Avatar
  • user578387 Avatar
  • belko-letyago Avatar
  • Unnamed Avatar
  • pablo.varela Avatar
  • suic Avatar
  • anter69 Avatar
  • user2300874 Avatar
  • donaldsebleung Avatar
  • Chrono79 Avatar
  • imjasonmiller Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • B1ts Avatar
  • Voile Avatar
  • Souzooka Avatar
  • FArekkusu Avatar
  • scottmyran Avatar
  • monadius Avatar
  • hobovsky Avatar
  • uniapi Avatar
  • Daniel-Worrall Avatar
  • markshevchenko Avatar
  • stellartux Avatar
  • qwertyu123 Avatar
  • lsnbr Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • yLaWy Avatar
  • fcr-- Avatar
  • KayleighWasTaken Avatar
Ad