Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Denenberg/7471bc1b385a87fbe86113d5c9dc92d7 to your computer and use it in GitHub Desktop.
Save Denenberg/7471bc1b385a87fbe86113d5c9dc92d7 to your computer and use it in GitHub Desktop.
Please, write a Python program that prints the first 5 numbers each of them is a product of 5 distinct primes...
# Please, write a Python program that prints the first 5 numbers
# each of them is a product of 5 distinct primes...
from sympy import primerange
def find_5_primes_product(limit):
primes = list(primerange(2, limit))
products = []
for i in range(len(primes) - 4):
for j in range(i+1, len(primes) - 3):
for k in range(j+1, len(primes) - 2):
for l in range(k+1, len(primes) - 1):
for m in range(l+1, len(primes)):
product = primes[i] * primes[j] * primes[k] * primes[l] * primes[m]
products.append(product)
products = sorted(list(set(products)))
return products
first_5 = find_5_primes_product(100)[:5]
print(first_5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment