def prime_generator(top = 0): primes: list = [] number = 1 while number < top: number += 1 if len(primes) == 0 and number == 2: primes.append(number) yield number j = len(primes) - 1 while j >= 0: if number % primes[j] == 0: break j -= 1 if j == -1: primes.append(number) yield number '''Проверка выражений''' prime_list = [n for n in prime_generator(258)] prime_gen_object = (n for n in prime_generator(123)) print(prime_list) print(prime_gen_object) for i in prime_gen_object: print(i, end=", ")