문제/백준_파이썬

43. 4673(셀프넘버)

sm_hope 2022. 5. 15. 10:31
def d(n) :
    n = n + sum(map(int, str(n))) 
    # n = n + n/10 + n%10
    return n

nonSelfNum = set()

for i in range(1, 10001):
    nonSelfNum.add( d(i) )

for j in range(1, 10001):
    if j not in nonSelfNum:
        print(j)

sum (변수) : 값을 더해준다.

map (변환 함수, 순회 가능한데이터)  : 각 데이터에 특정한 함수를 적용 시킴

str(변수) : 값을 문자열로 변환

set() : 집합 -> 중복을 허용하지 않는다.