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

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad