var a; a = parseInt(prompt("数値を入力してください")); var b = 0; for (var i = 1; i <= a; i++){ b += i; } alert("1から入力した数値の整数の和は「" + b + "」です");