Skip to content

Commit

Permalink
2024-05-07 2737 연속합
Browse files Browse the repository at this point in the history
  • Loading branch information
seongwon030 committed May 6, 2024
1 parent ef99fe7 commit 06f49c9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions seongwon030/수학/연속 합.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import math

n = int(input())
for i in range(n):
cnt = 0
k = int(input())
j = 2 # 적어도 2개 이상의 연속된 자연수의 합
while True:
center_first = math.floor(k / j) # center 값을 초기화
div = j // 2
if center_first < div:
break
if j % 2 == 0:
if ((center_first + center_first + 1) * div == k):
cnt += 1
elif j % 2 == 1:
if ((center_first * 2 * div + center_first) == k):
cnt += 1
j += 1
print(cnt)

0 comments on commit 06f49c9

Please sign in to comment.