알고리즘

[프로그래머스] 숫자의 표현

hminor 2023. 6. 2. 22:21
def solution(n):
    answer, cnt = 0, 1
    while cnt <= n:
        hap = 0
        for i in range(cnt,n+1):
            hap += i
            if hap < n: continue
            else: 
                if hap == n: answer += 1
                cnt += 1
                break
    return answer