num = int(input("いくつまでの総和?")) total = 0 for n in range(1, num+1): total += n print(f"{num}までの総和は{total}です。") # プログラム6-18(入力された数までの総和)