Goldbach's comet: Difference between revisions

Content added Content deleted
Line 281: Line 281:
from sympy import isprime
from sympy import isprime


def prime_duo_partitions(n):
def g(n):
assert n > 2 and n % 2 == 0, 'n in goldbach function g(n) must be even'
if isprime(n):
yield (n,)
count = 0
for i in range(1, n//2 + 1):
for i in range(1, n//2 + 1):
if isprime(i) and isprime(n - i):
if isprime(i) and isprime(n - i):
yield (i, n - i)
count += 1
return count

def g(n):
assert n > 2 and n % 2 == 0, 'n in goldbach function g(n) must be even'
return len(list(prime_duo_partitions(n)))


print('The first 100 G numbers are:')
print('The first 100 G numbers are:')
Line 321: Line 318:
The value of G(1000000) is 5402
The value of G(1000000) is 5402
</pre>
</pre>



=={{header|Raku}}==
=={{header|Raku}}==