Study/Algorithm 문제풀이
[SW Expert Academy] 2025. N줄 덧셈(using python)
상꼬
2021. 1. 31. 23:03
728x90
반응형
* 문제의 저작권은 SW Expert에 있습니다.
swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5QFZtaAscDFAUq
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[ 문 제 ]
1부터 주어진 숫자만큼 모두 더한 값을 출력하시오.
단, 주어질 숫자는 10000을 넘지 않는다.
[ 예 제 ]
주어진 숫자가 10 일 경우 출력해야 할 정답은,
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55

[ 전체코드 ]
T = int(input())
result = 0
for i in range(1, T+1):
result += i
print(result)
# 한 줄 코딩
print(sum([i for i in range(1, int(input())+1)]))
#######################################################################################
728x90
반응형