This is a Python Program to print all integers that aren’t divisible by either 2 or 3 and lies between 1 and 50.

The program prints all integers that aren’t divisible by either 2 or 3 and lies between 1 and 50.

1. Use a for-loop ranging from 0 to 51.

2. Then use an if statement to check if the number isn’t divisible by both 2 and 3.

3. Print the numbers satisfying the condition.

4. Exit.

Here is source code of the Python Program to print all integers that aren’t divisible by either 2 or 3 and lies between 1 and 50. The program output is also shown below.

for i in range(0,51): if(i%2!=0&i%3!=0): print(i)

1. The for loop ranges from 0 to 50 (as 51 isn’t exclusive).

2. The expression within the if-statement checks if the remainder obtained when the number divided by 2 and 3 is one or not.

3. If the remainder isn’t equal to 0, the number isn’t divisible by either 2 and 3.

4. The number satisfying the condition is printed.

Case 1: 1 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49

**Sanfoundry Global Education & Learning Series – Python Programs.**

To practice all Python programs, __here is complete set of 150+ Python Problems and Solutions__.