## very simple recursion examples.
def repeat(n, ch):
"""prec: n is an ineger, ch is a one-character string
postc: returns a string of length n containing the character ch."""
pass
def print_repeat(n, ch):
"""prec: n is an ineger, ch is a one-character string
postc: print a string of length n containing the character ch."""
pass
def main():
print(repeat("*", 5))
print_repeat("*", 5)
main()
## very simple recursion examples.
def repeat(n, ch):
"""prec: n is an ineger, ch is a one-character string
postc: returns a string of length n containing the character ch."""
if n == 0:
return ""
return repeat(n - 1, ch) + ch
def print_repeat(n, ch):
"""prec: n is an ineger, ch is a one-character string
postc: print a string of length n containing the character ch."""
if n == 0:
return
print(ch, end = "")
print_repeat(n - 1, ch)
def main():
print(repeat(50, "*"))
print_repeat(50, "*")
main()