Skip to content

Commit

Permalink
Add Python script for indirect recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
schedutron committed Oct 30, 2018
1 parent a1ded75 commit adcde4d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions print1toN/indirect_recursion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Script to print 1 to N using indirect recursion in Python3"""

def printer1(n):
if n >= 1:
print(n)
printer2(n-1)


def printer2(n):
if n >= 1:
print(n)
printer1(n-1)


if __name__ == "__main__":
n = int(input("Enter a natural number: "))
printer1(n)

0 comments on commit adcde4d

Please sign in to comment.