Find elements

Python program to check odd or even using recursion

Python program to check odd or even using recursion

In this tutorial, we will discuss a concept of the  Python program to check odd or even using recursion

In this article, we are going to learn  how to  check  odd and even numbers using recursion in the

Python programming language

Check odd or even using recursion

What is an even or odd number?

When any integer ends in 0,2,4,6,8 and it can be divided by two with the remainder of zero, it is called as an even number.

Example of even numbers – 34,-64,78,788

When any integer ends in 0,1,3,5,7,9 and it cannot be divided without a remainder, it is called as an odd number.

Example for odd numbers – 33,-69,75,785

 

Here, We can use Python operators to find odd or even number in given numbers

Python program to check odd or even using recursion

Program 1

This program allows the user to enter a number and is used to check whether the given number is odd or even using recursion

def isEven(num):
     if(num<2):
         return (num%2 == 0)
     return (isEven(num-2))
num=int(input("Enter the number for check odd or even: "))
#received input from the user and stored variable nnm
if(isEven(num)==True):
#pass the number as an argument to the recursive function
    print(num,"is an even number")
else:
    print(num,"is an odd number")

When the above code is executed, it produces the following results

Case 1

Enter the number for check odd or even: 235
(235, 'is an odd number')

 

Case 2

Enter the number for check odd or even: 346
(346, 'is an even number')

 

Similar post

Python code to check whether a number is odd or even

Python program to check a number is even or odd using the function

Python program to display even and odd numbers without if

Python code to display even and odd number in the given range

Separate odd and even numbers in a list to different two list

Python code to find odd and even numbers from a list

 

Suggested for you

Function in Python

Recursion in Python

If statement in Python

Operator in Python

 

 

C++ program to check odd or even using recursion
Calculate the average of odd and even numbers in C
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

1 day ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago