0
I am trying to create a recursive function that takes a positive integer number N and prints all even numbers from 0 to N in ascending order.
I’m only managing to do the opposite, that is, print the numbers down. Below will be the code that I built, but it does not perform the task you want. Already, I want to thank for the help and attention of all who will cooperate.
def sequencia_de_numero(number):
if number == 0:
print(number)
else:
if number % 2 == 0:
print(number)
return sequencia_de_numero(number -1)
else:
return sequencia_de_numero(number - 1)
And what is the purpose of an example of recursive factorial in this question?
– Woss
Because this function is recursive, and demonstrates recursion
– Felipe Soares