#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Sat Dec 3 18:16:57 2016 @author: taylor@mst.edu """ def is_even(no: int) -> bool: print("Calling isOdd with: ", no) if 0 == no: return True else: return is_odd(no - 1) def is_odd(no: int) -> bool: print("Calling isOdd with: ", no) if 0 == no: return False else: return is_even(no - 1) for n in range(10): # OK but comprehensible way to detect even/odd if n % 2 == 0: print(n, "is even") else: print(n, "is odd") # Fastest way with bitwise operator # (just & with last bit, not whole number division) if n & 1 == 0: print(n, "is even") else: print(n, "is odd") # A terribly ineffecient way to detect even/odd if is_even(n): print(n, "is even") else: print(n, "is odd")