728x90
20240504 백준 파이썬 공부
9713번 Sum of Odd Sequence
1. 문제
Given an odd integer N,
calculate the sum of all the odd integers between 1 and N inclusive.
2. 입력
First line of the input contains T, the number of test cases.
Each test case contains a single integer N. N is between 1 and 100.
3. 출력
For each test case output the value 1+3+….+N.
>>>코드
for _ in range(int(input())):
result = 0
n = int(input())
for i in range(1, n+1):
if i%2 == 1:
result += i
print(result)
728x90
'백준 > 백준 파이썬' 카테고리의 다른 글
백준 파이썬 2309번 일곱 난쟁이 (Today I Learn 2024.05.06) (0) | 2024.05.06 |
---|---|
백준 파이썬 10093번 숫자 (Today I Learn 2024.05.05) (0) | 2024.05.05 |
백준 파이썬 2748번 피보나치 수 2 (Today I Learn 2024.05.03) (0) | 2024.05.03 |
백준 파이썬 2747번 피보나치 수 (Today I Learn 2024.05.02) (0) | 2024.05.02 |
백준 파이썬 5635번 생일 (Today I Learn 2024.05.01) (0) | 2024.05.01 |