n = int(input('n = ')) if n < 2: print("No prime numbers in the given range") else: deleted = [False] * (n + 1) i = 2 while i * i <= n: if not deleted[i]: j = i * i while j <= n: deleted[j] = True j += i i += 1 for i in range(2, n+1): if not deleted[i]: print(i, end = " ") |