Write a python function to generate Euclid Number Series(2, 3, 7, 31, 211, 2311, 30031)


Topic: Write a python function to generate Euclid Number Series(2, 3, 7, 31, 211, 2311, 30031)

Solution

from math import sqrt
from itertools import count, islice
def is_prime(n):
    return n > 1 and all(n % i for i in islice(count(2), int(sqrt(n)-1)))
def euclid_numbers(n):
    product = 1
    if n > 3:
        for i in range(n):
            if is_prime(i):
                product = product * i
                yield product
                
         
         



List all Python Programs