Answer to Question #194908 in Python for desmond

Question #194908

Design a recursive function that accepts an integer argument, n, and prints every second number from n down to a minimum of 0. Assume that n is always a positive integer.


1
Expert's answer
2021-05-20T11:49:23-0400
def recursiveFunction(x):
    c=1
    if(x==0):
        print(x)
    else:
        recursiveFunction(x-1)
        if(x%2==0):
            print(x)

recursiveFunction(30)

Output:


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS