5 kyu

Number of trailing zeros of N!

146 of 56,955Ivan 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 Trained128362
Total Skips24297
Total Code Submissions346641
Total Times Completed56955
CoffeeScript Completions146
JavaScript Completions13249
Ruby Completions1735
Haskell Completions1074
Clojure Completions331
Python Completions21055
Java Completions8664
C# Completions3515
Objective-C Completions25
C++ Completions4585
C Completions2061
R Completions149
NASM Completions31
Rust Completions1199
Groovy Completions48
Scala Completions316
Prolog Completions25
F# Completions46
Crystal Completions19
COBOL Completions13
Go Completions658
Lua Completions109
Factor Completions13
Swift Completions175
D Completions15
OCaml Completions38
Julia Completions18
Total Stars2288
% of votes with a positive feedback rating84% of 4869
Total "Very Satisfied" Votes3611
Total "Somewhat Satisfied" Votes924
Total "Not Satisfied" Votes334
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