Skip to content

Instantly share code, notes, and snippets.

@amitpatelx
Created August 26, 2021 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitpatelx/41d373ca31a8280964a2e14471c9d5e9 to your computer and use it in GitHub Desktop.
Save amitpatelx/41d373ca31a8280964a2e14471c9d5e9 to your computer and use it in GitHub Desktop.
Number of trailing zeros of N!
# 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