def f( x ) sum = 0 (1..x).each { |i| sum += i } return sum end i = gets.to_i printf( "1から%dまでの合計値は%dです\n" , i , f( i ) )