목록코드트리 #재귀함수 (2)
배우고 느낀 것들
[코드트리] 홀수 짝수에 따른 출력값 (미해결)
🍒 문제 링크 https://www.codetree.ai/missions/5/problems/output-value-based-on-odd-even-numbers/explanation 🍒 문제 분석 🍒 내 코드 N = int(input()) def f(N): if N
카테고리 없음
2022. 9. 11. 17:23
[코드트리] 1이 되는 순간까지 (미해결)
🍒 문제 링크 https://www.codetree.ai/missions/5/problems/until-the-moment-I-reach-one/introduction 🍒 문제 분석 진행한 작업의 횟수 -> cnt 변수를 설정하고 거기에 누적하여 더하려고 했음. N % 2 == 0 을 통해 조건을 구분지어 f(N // 2) 혹은 f(N // 3) 을 return 🍒 내 코드 N = int(input()) def f(N): cnt = 0 if N == 0: return cnt # 처음엔 return N으로 했다가 수정 else: if (N % 2) == 0: cnt += 1 return f(N // 2) else: cnt += 1 return f(N // 3) print(f(N)) 🍓 내 해결 과정 idl..
파이썬/문제
2022. 9. 11. 17:19