def odd(n):
#return n%2 == 1
if n == 0:
return False
return even(n-1)
def even(n):
#return n%2 == 0
if n == 0:
return True
return odd(n-1)
odd(4)
False
odd(3) = even(2) = odd(1) = even(0) = True
def insert(x,nums):
#i = 0
#while i < len(nums) and x >= nums[i]:
# i = i + 1
#return nums[0:i] + [x] + nums[i:]
#BASE CASE - do not forget
if nums == []:
return [x]
if x <= nums[0]:
return [x] + nums
return [nums[0]] + insert(x,nums[1:])
def isort(nums):
if nums == []:
return []
return insert(nums[0],isort(nums[1:]))
isort([20,10,30])
[10, 20, 30]