취미와 밥줄사이
[Algorithm] 백준8393번: 합 본문
문제
n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오.
입력
첫째 줄에 n (1 ≤ n ≤ 10,000)이 주어진다.
출력
1부터 n까지 합을 출력한다
예제 입력 1
3
예제 출력 1
6
문제 풀이
N = int(input()) # 정수 입력
sumNumber = 0
for i in range(1, N+1):
sumNumber = sumNumber + i #
print(sumNumber)
REFERENCE
https://www.acmicpc.net/problem/8393
8393번: 합
n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오.
www.acmicpc.net
'Python > 알고리즘' 카테고리의 다른 글
[Algorithm] 백준 11022번: A+B-8 (0) | 2021.11.29 |
---|---|
[Algorithm] 백준 11021번: A+B-7 (0) | 2021.11.28 |
[Algorithm] 백준 15552번: 빠른 A+B (0) | 2021.11.28 |
[Algorithm] 백준10950번: A+B -3 (0) | 2021.11.28 |
[Algorithm] 백준2739: 구구단 (0) | 2021.11.28 |