232k views
4 votes
Write a new recursive function countup that expects a negative argument and counts "up" from that number. Output from running the function should look something like this:__________.

>>> countup(-3)
-3
-2
-1
Blastoff!

User Atul Verma
by
5.3k points

1 Answer

6 votes

Answer:

function:

def countup(n):

if(n<0):

print(n)

countup(n+1)

else:

print("Blastoff!")

Output:

  • If the user pass (-3) for the value of n, then it will prints the above output.

Step-by-step explanation:

  • The above code is in python language, which has a function of "countup" which will print the all decrement value of n until the value is less than 0.
  • The above function is a recursive function that will give the output if the user gives it a negative value, otherwise, it will print "Blastoff!" for any positive or zero value.

User Nicolas BADIA
by
4.2k points