Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

number of trailing zeros in a factorial of a number.

# Number of trailing zeros in a factorial of a number

def zeros(n)
  zeros = 0
  while (n > 0) 
    n = (n / 5).floor
    zeros += n
  end
  zeros  
end

print "Number of trailing zeros = ", zeros(6);   # 1
print "
Number of trailing zeros = ", zeros(30);  # 7
Comment

PREVIOUS NEXT
Code Example
Ruby :: ruby array with unique values 
Ruby :: ruby get min value from array 
Ruby :: ruby remove nil element in array 
Ruby :: ! in ruby 
Ruby :: force stop rails server 
Ruby :: online ruby compiler 
Ruby :: sequel ruby alias table 
Ruby :: rails class note reminders 
Ruby :: rails image 
Ruby :: ruby new class params 
Ruby :: ruby 3 one line method 
Ruby :: name error on ruby 
Ruby :: ruby regex replace capture group 
Ruby :: rails generate controller without view ,test 
Ruby :: after_create for STI rails 
Ruby :: capybara click with offset 
Ruby :: ruby get haft of array 
Ruby :: get specific key value from array of hashes in ruby 
R :: dplyr replace na 
R :: generate all possible combinations of a set of characters r 
R :: how to match two time series in r 
R :: r dataframe column factor 
R :: r language comment 
R :: how to change the numbering of rows in r 
R :: ggplot2 graph in r 
R :: how to summarise data but keep columns R 
R :: boucle sur r 
R :: if condition is met skip to next iteration in a for loop in r 
R :: read delim in r with lapply read.delim sep 
R :: Which library allows modification of Excel files from R 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =