Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Recursion] bj17478- 재귀함수가 뭔가요? #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions recursion/bj17478.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 17478번 - 재귀함수가 뭔가요?

n = int(input())

def recursion(i, n) :
print("____" * i + '"재귀함수가 뭔가요?"')
if i == n :
print("____" * i + '"재귀함수는 자기 자신을 호출하는 함수라네"')
else :
print("____" * i + '"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.')
print("____" * i + '마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.')
print("____" * i + '그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어."')
recursion(i + 1, n)
print("____" * i + "라고 답변하였지.")

print("어느 한 컴퓨터공학과 학생이 유명한 교수님을 찾아가 물었다.")
recursion(0, n)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n 을 넘겨주니까 n에 대해서 전역변수로 n을 몰라도 되니까 좋은거 같네요 저도 매개변수로 넘겨주어야 겠습니다

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오.. 이게 나은 거구나~!