Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- import math
- def is_prime(n):
- if n <= 1:
- return False
- elif n <= 3:
- return True
- elif n % 2 == 0 or n % 3 == 0:
- return False
- i = 5
- while i * i <= n:
- if n % i == 0 or n % (i + 2) == 0:
- return False
- i += 6
- return True
- # Here I use odd primes only
- def get_primes_up_to_N(N):
- primes = []
- num = 3
- while len(primes) < N:
- if is_prime(num):
- primes.append(num)
- num += 1
- return primes
- N = 3
- while True:
- primes = get_primes_up_to_N(N)
- # Generate N distinct primes raised to 6
- my_list = [prime ** 6 for prime in primes]
- combinations = list(itertools.combinations(my_list, 3))
- get_the_sums = []
- for i in combinations:
- get_the_sums.append(sum(i))
- #See if get_the_sums has no duplicates
- # If there is no duplicates then there should be no
- # collisions for subset sum
- print('The size of the Universe: ',N, 'No duplicate sums: ',len(get_the_sums) == len(set(get_the_sums)))
- N = N + 3
- if len(get_the_sums) != len(set(get_the_sums)):
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement