Blocks

  • + 0 comments
    def factorial(n)
        yield(n)
    end
    n = gets.to_i
    puts factorial(n) { (1..n).reduce(1, :*) }