Skip to content

Instantly share code, notes, and snippets.

@mym0404
Created May 17, 2022 07:14
Show Gist options
  • Save mym0404/cb2b0589bb5f6a19965e7d3946b4a1fd to your computer and use it in GitHub Desktop.
Save mym0404/cb2b0589bb5f6a19965e7d3946b4a1fd to your computer and use it in GitHub Desktop.
n = int(input())
print("어느 한 컴퓨터공학과 학생이 유명한 교수님을 찾아가 물었다.")
def fn(depth):
prefix = "_" * depth * 4
print(prefix, end='"재귀함수가 뭔가요?"\n')
if n == depth:
print(prefix, end='"재귀함수는 자기 자신을 호출하는 함수라네"\n')
else:
print(prefix, end='"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.\n')
print(prefix, end='마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.\n')
print(prefix, end='그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어."\n')
fn(depth + 1)
print(prefix, end='라고 답변하였지.\n')
fn(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment