Created
February 5, 2023 14:53
-
-
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...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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