title: "[프로그래머스] 콜라츠 추측 Python 파이썬 해설 (Level 1) - 이도훈"
cleanUrl: "programmers/12943"
description: "프로그래머스 Level 1 문제 [콜라츠 추측]의 풀이를 정리합니다."
def solution(num):
cnt = 0
while num != 1:
if num % 2 == 0:
num //= 2
else:
num = 3 * num + 1
cnt += 1
if cnt == 500:
return -1
return cnt
프로그래머스 코딩테스트 연습 https://school.programmers.co.kr/learn/challenges