Tuesday, 2 July 2019

Factorial program using ruby

def factorial_no
  yield
end

n=gets.to_i
factorial_no do
  (1..n).reduce(:*)
end


No comments:

Post a Comment

Interactor in Rails

What is interactor? Interactor provides a common interface for performing complex user interactions An interactor is a simple, sin...