Blocks

  • + 0 comments
    def factorial(n, i)
        yield(n, i)
    end
    
    n = gets.to_i
    i = n - 1
    puts factorial(n, i) { 
        while i != 0
            n = n * i
            i -= 1
        end
        n
    }