Created
August 26, 2021 03:46
-
-
Save amitpatelx/41d373ca31a8280964a2e14471c9d5e9 to your computer and use it in GitHub Desktop.
Number of trailing zeros of N!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.codewars.com/kata/52f787eb172a8b4ae1000a34/train/ruby | |
# Number of trailing zeros of N! | |
def zeros(n) | |
(1..n).inject(1) {|fact, num| fact * num }.to_s.count('0') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment