In this example we will show how to print integers that cannot be divisible by 2,3, and 5 between 1 and the specified upper limit in Python.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input("Please input the upper limit: "))
for i in range(1, n+1):
if i % 2 != 0 and i % 3 != 0 and i % 5 != 0:
print(i, sep=" ", end=" ")
Output:
Please input the upper limit: 60
1 7 11 13 17 19 23 29 31 37 41 43 47 49 53 59