π¬ λ¬Έμ μ€λͺ
μ μ nμ μ
λ ₯λ°μ nμ μ½μλ₯Ό λͺ¨λ λν κ°μ 리ν΄νλ ν¨μ, solutionμ μμ±ν΄μ£ΌμΈμ.
π μ ν μ¬ν
- nμ 0 μ΄μ 3000μ΄νμΈ μ μμ λλ€.
π‘ λμ νμ΄
def solution(n):
answer = 0
for i in range(1,n+1):
if n % i == 0:
answer += i
return answer
π‘ λ€λ₯Έ ν΄μ€
def sumDivisor(num):
# num / 2 μ μλ€λ§ κ²μ¬νλ©΄ μ±λ₯ μ½ 2λ°° ν₯μ
return num + sum([i for i in range(1, (num // 2) + 1) if num % i == 0])
ππ» λ¬Έμ λ°λ‘κ°κΈ°
'Coding > Code in the Morning' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
211206_Code in the morning (0) | 2021.12.07 |
---|---|
211206_Code at Night βοΈ (0) | 2021.12.06 |
211126_Code in the morning (0) | 2021.11.26 |
211123_Code int the morning (0) | 2021.11.23 |
211103_Code in the morning (0) | 2021.11.03 |