Python 3: Recursivley find if number is even
- by pythonhack
I am writing a program that must find if a number is even or not. It needs to follow this template. I can get it to find if a number is even or not recursively (call function and subtract 2, base case zero), but I am having a hard time following this template, based on how the isEven function is called in the main function. Any help would be greatly appreciated.
Write a recursive function called isEven that finds whether a number is even or not:
def isEven()
#recursivley determine whether number is even or not
def main():
number=int(input(“Enter a number : “))
if (isEven(number)):
print(“Number is even”)
else:
print(“Number is not even”)
main()
Thank you! Appreciate it.