class Total attr_reader :n def initialize(n: 0) @n = n end def datainput begin @n = Integer(gets.chomp) rescue end end def dataoutput puts (1..@n).inject(:+) end def run datainput dataoutput end end if $0 == __FILE__ Total.new.run end