### Python Program to Print all Integers that are not Divisible by Either 2 or 3 and Lie between 1 and 50

Problem Description:
The program prints all integers that aren%u2019t divisible by either 2 or 3 and lies between 1 and 50. Problem Solution:
1. Use a for-loop ranging from 0 to 51. 2. Then use an if statement to check if the number isn%u2019t divisible by both 2 and 3. 3. Print the numbers satisfying the condition. 4. Exit. Python Program/Source Code:
#Python Program to Print all Integers that Aren't Divisible by Either 2 or 3 and Lie between 1 and 50. class divisibility: def divide(self): for i in range(1,51): if i%2!=0 and i%3!=0: print(i) def main(): obj=divisibility() obj.divide() if __name__ == '__main__': main() Program Explanation:
1. The for loop ranges from 0 to 50 (as 51 isn%u2019t 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%u2019t equal to 0, the number isn%u2019t divisible by either 2 and 3. 4. The number satisfying the condition is printed. Runtime Test Cases:
1 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49

#### More Articles of Anurag Jain:

Name Views Likes
Python Program to Remove the Duplicate Items from a List 770 10
Python Program to Construct a Tree & Perform Insertion, Deletion, Display 790 0
Python Program to Count Number of Leaf Node in a Tree 1485 0
Python Program to Create a Mirror Copy of a Tree and Display using BFS Traversal 920 0
Python GUI application to record a video using Tkinter GUI module and openCV computer vision library 7113 0
Python Program to Find the Number of Nodes in a Binary Tree 830 0
Python Program to Add a Key-Value Pair to the Dictionary 725 0
Python Program to Map Two Lists into a Dictionary 969 0
Python Program for Depth First Binary Tree Search using Recursion 853 0
Python program to get disk name and its vendor from Linux/UNIX like system and return in a dictionary like structure 834 0
Python Program for face Detection using openCV and haar-cascades 1480 0
Python Program to Implement Introsort 1107 0
Python Program to Find the Largest value in a Tree using Inorder Traversal 702 0
Python Program to Print all Integers that are not Divisible by Either 2 or 3 and Lie between 1 and 50 1368 23
Python Program to Generate a Dictionary that Contains Numbers (between 1 and n) in the Form (x,x*x) 1056 0
Python Program to Remove the ith Occurrence of the Given Word in a List where Words can Repeat 1446 10
Python Program to Implement Radix Sort 1206 0
Python Program to Print Border of given Tree in Anticlockwise Direction 819 0
Python Program to Print all Numbers in a Range Divisible by a Given Number 987 17
Python Program to Remove All Tuples in a List of Tuples with the USN Outside the Given Range 1132 0
Python Program to Read Height in Centimeters and then Convert the Height to Feet and Inches 879 13
Python Program to Find Nth Node in the Inorder Traversal of a Tree 1055 0
Python Program to Construct a B Tree 5639 0
Python Program to Implement Depth First Search Traversal using Post Order 980 0
Python Program to Sum All the Items in a Dictionary 960 0
Python Program to Check if a Number is a Perfect Number 930 15
Python Program to Build Binary Tree if Inorder or Postorder Traversal as Input 1146 0
Python Program to Form a Dictionary from an Object of a Class 959 0
Python Program to Remove the Given Key from a Dictionary 811 0
Python Program to Count Number of Non Leaf Nodes of a given Tree 788 0
Python Program to Generate Gray Codes using Recursion 960 22
Python Program to Compute Simple Interest Given all the Required Values 890 21
Python Program to Check Whether a Number is Positive or Negative 825 25
Python Program to Read a List of Words and Return the Length of the Longest One 1333 10
Python GUI application to record a video using tkinter GUI module and openCV 62 6
Python Program for Depth First Binary Tree Search without using Recursion 851 0
Python Program to Create a Dictionary with Key as First Character and Value as Words Starting with that Character 2473 0
Python program to get disk information, health, short test results using Smartctl one of Smartmoontools for disk analysis using Linux system 884 1
Python Program to Multiply All the Items in a Dictionary 1360 0
Python Program to Construct a Binary Search Tree and perform deletion and inorder traversal 1186 0
Python Program to Concatenate Two Dictionaries Into One 891 0
Python Program to Check if a Number is a Prime Number 764 22
Python Program to Swap the First and Last Value of a List 1105 22
Python Program to Demonstrate Circular Single Linked List 835 0
Python Program to Check if a Given Key Exists in a Dictionary or Not 775 0