[ํ๋ก๊ทธ๋๋จธ์ค-Lv1] ์ฝ์์ ๊ฐ์์ ๋ง์
/ Python
๐ Problem Solving/Programmers
def divisor(num):
cnt = 0
for i in range(1, num + 1):
if num % i == 0:
cnt += 1
if cnt % 2 == 0:
return True
else:
return False
def solution(left, right):
answer = 0
for i in range(left, right + 1):
if divisor(i):
answer += i
else:
answer -= i
return answer
ํด์ค
์ฝ์์ ๊ฐ์๊ฐ ์ง์๋ฉด ๋ํ๊ณ , ํ์๋ฉด ๋บ๋ค!
'๐ Problem Solving > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค-Lv1] 3์ง๋ฒ ๋ค์ง๊ธฐ / Python (0) | 2021.06.02 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค-Lv1] ์์ฐ / Python (0) | 2021.06.02 |
[ํ๋ก๊ทธ๋๋จธ์ค-Lv1] ์คํจ์จ / Python (0) | 2021.06.01 |
[ํ๋ก๊ทธ๋๋จธ์ค-Lv1] ํคํจ๋ ๋๋ฅด๊ธฐ / Python (0) | 2021.06.01 |
[ํ๋ก๊ทธ๋๋จธ์ค-Lv1] ์์ ๋ํ๊ธฐ / Python (0) | 2021.06.01 |