Q. 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.
You can understand by Watching video :-
Answer :-
n = int(input("Enter n = "))
m = int(input("Enter m as divisor = "))
for i in range(1,n):
if i % m == 0 :
if i % 2 == 0 :
print(i,"is divisible by m and this is even number ")
else :
print(i,"is divisible by m and this is odd number ")
Output :-
Enter n = 10
Enter m as divisor = 2
2 is divisible by m and this is even number
4 is divisible by m and this is even number
6 is divisible by m and this is even number
8 is divisible by m and this is even number
>>>
Enter n = 15
Enter m as divisor = 3
3 is divisible by m and this is odd number
6 is divisible by m and this is even number
9 is divisible by m and this is odd number
12 is divisible by m and this is even number
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )