Blocks

  • + 0 comments

    def factorial yield end

    n = gets.to_i factorial do f=1 (1..n).map { |a| f=f*a} puts f end