Thursday 19 September 2024

Practical - 71 - Write a program in python to print all the numbers between 1 to 100 which are either divisible by 3 or 5.

Practical - 71 - Write a program in python to print all the numbers between 1 to 100 which are either divisible by 3 or 5.


Ans:

for i in range(1,101):

    if i%3==0 or i%5==0:

        print(i,end=" ")

 

Output:

3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 


No comments:

Post a Comment