223. 반복수열

아현·2021년 7월 21일
0

Algorithm

목록 보기
233/400

백준





1. Python


num, p = map(int, input().split())

nums = [num]

while True:
  ans = 0
  for n in str(nums[-1]):
    ans += int(n) ** p
  
  if ans in nums:
    break

  nums.append(ans)

print(nums.index(ans))


profile
Studying Computer Science

0개의 댓글