#!/usr/bin/env ruby # coding: utf-8 print("いくつまでの合計を数えますか。\n") n=gets.to_i sam=0 while n>0 sam+=n n-=1 end printf("%d\n",sam)