Programming Examples

Python program to print every integer between 1 and n divisible by m Also report whether the number that is divisible by m is even or odd


Write a Python program to print every integer between 1 and n divisible by m. Also report whether the number that is divisible by m is even or odd.

m = int(input("Enter m: "))
n = int(input("Enter n: "))
for i in range(1, n) :
    if i % m == 0 :
        print(i, "is divisible by", m)
        if i % 2 == 0 :
            print(i, "is even")
        else :
            print(i, "is odd")

Output

Enter m: 3

Enter n: 20

3 is divisible by 3

3 is odd

6 is divisible by 3

6 is even

9 is divisible by 3

9 is odd

12 is divisible by 3

12 is even

15 is divisible by 3

15 is odd

18 is divisible by 3

18 is even

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad