def sieve_of_eratosthenes(n): nums = list(range(2, n)) while nums: prime = nums[0] nums = [i for i in nums if i % prime] yield prime def main(): num = 0 another = True while another: try: num = int(input()) another = False except ValueError: pass print() for i in sieve_of_eratosthenes(num): print(i) if __name__ == "__main__": main()