How to make it direct recursion? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

How to make it direct recursion?

def is_even(x): if x == 0: return True else: return is_odd(x-1) def is_odd(x): return not is_even(x) print(is_odd(17)) print(is_even(23))

9th May 2021, 6:58 AM
Nafi Rahat Rahman
1 Réponse
- 1
def is_even(x): return not x & 1 # Hope this helps
9th May 2021, 7:36 AM
Calvin Thomas
Calvin Thomas - avatar