Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	prime := make([]int, 1000001)
	prime[0], prime[1] = -1, -1
	for i := 2; i < 1000001; i++ {
		if prime[i] != -1 {
			prime[i] = 1 // i means "prime"
			for j := i+i; j < 1000001; j += i {
				prime[j] = -1 // -1 means "not prime"
			}
		}
	}
	for scanner.Scan() {
		ret := 0
		a, _ := strconv.Atoi(scanner.Text())
		if a == 0 {
			break
		}
		for i := 1; i <= a/2; i++ {
			if prime[i] == 1 && prime[a-i] == 1 {
				ret++
			}
		}
		fmt.Println(ret)
	}
}

Python: # AOJ 0185 Goldbach's Conjecture II
# Python3 2018.6.20 bal4u

MAX = 1000000
SQRT = 1000     # sqrt(MAX)

prime = [True for i in range(MAX)]
prime[1] = False

def sieve():
	for i in range(3, SQRT, 2):
		if prime[i] is True:
			for j in range(i*i, MAX, i):
				prime[j] = False
sieve()

print(prime[1:20:2])

while True:
	n = int(input())
	if n == 0: break
	i = j = n >> 1
	if (i & 1) == 0:
		i -= 1
		j += 1
	ans = 0
	while i > 0:
		if prime[i] and prime[j]: ans += 1
		i -= 2
		j += 2
	print(ans)

Python: import array
import bisect


def is_prime_number(num):
    limit = int(num ** 0.5)

    for lp in range(3, limit + 1, 2):
        if num % lp == 0:
            return False

    return True


LENGTH = 1000000
prime_number_list = array.array("i", [True] * (LENGTH + 1))

prime_number_list[0] = False
prime_number_list[1] = False

for lp in range(4, LENGTH + 1, 2):
    prime_number_list[lp] = False

limit = int((LENGTH + 1) ** 0.5)

for lp in range(3, limit + 1, 2):
    if is_prime_number(lp):
        for lp2 in range(lp * 2, LENGTH + 1, lp):
            prime_number_list[lp2] = False

prime_number_list = array.array("i", [index for index, item in enumerate(prime_number_list) if item])

while True:

    input_num = int(input())

    if input_num == 0:
        break

    count = 0

    array_size = bisect.bisect_left(prime_number_list, input_num // 2)

    for lp in prime_number_list[:array_size + 1]:

        search_num = input_num - lp

        index = bisect.bisect_left(prime_number_list, search_num)

        if prime_number_list[index] == search_num:
            count += 1

    print(count)

Python: MAX = 1000001
primes = list()
for i in range(MAX):
    primes.append(True)
primes[0] = False
primes[1] = False

for i in range(2, MAX):
    j = i + i
    while j < MAX:
        primes[j] = False
        j = j + i

while True:
    n = int(input())
    if n == 0:
        break

    ans = 0
    for i in range(1, n // 2 + 1):
        if primes[i] and primes[n-i]:
            ans += 1
    print(ans)

Python: import array


def is_prime_number(num):
    limit = int(num ** 0.5)

    for lp in range(3, limit + 1, 2):
        if num % lp == 0:
            return False

    return True


LENGTH = 1000000
prime_number_list = array.array("i", [True] * (LENGTH + 1))

prime_number_list[0] = False
prime_number_list[1] = False

for lp in range(4, LENGTH + 1, 2):
    prime_number_list[lp] = False

limit = int((LENGTH + 1) ** 0.5)

for lp in range(3, limit + 1, 2):
    if is_prime_number(lp):
        for lp2 in range(lp * 2, LENGTH + 1, lp):
            prime_number_list[lp2] = False

while True:
    input_num = int(input())

    if input_num == 0:
        break

    count = 0

    for lp in range(2, input_num // 2 + 1):

        if prime_number_list[lp] and prime_number_list[input_num - lp]:
            count += 1

    print(count)

Python: import array
import bisect


def is_prime_number(num):
    limit = int(num ** 0.5)

    for lp in range(3, limit + 1, 2):
        if num % lp == 0:
            return False

    return True


def binary_search(num_list, num):
    left = 0
    right = len(num_list)

    while left <= right:
        mid = (left + right) // 2

        if num_list[mid] == num:
            return True
        elif num_list[mid] < num:
            left = mid + 1
        else:
            right = mid - 1

    return False


LENGTH = 1000000
prime_number_list = array.array("i", [True] * (LENGTH + 1))

prime_number_list[0] = False
prime_number_list[1] = False

for lp in range(4, LENGTH + 1, 2):
    prime_number_list[lp] = False

limit = int((LENGTH + 1) ** 0.5)

for lp in range(3, limit + 1, 2):
    if is_prime_number(lp):
        for lp2 in range(lp * 2, LENGTH + 1, lp):
            prime_number_list[lp2] = False

prime_number_list = array.array("i", [index for index, item in enumerate(prime_number_list) if item])

while True:

    input_num = int(input())

    if input_num == 0:
        break

    count = 0

    array_size = bisect.bisect_left(prime_number_list, input_num // 2)

    for lp in prime_number_list[:array_size + 1]:

        search_num = input_num - lp

        if binary_search(prime_number_list, search_num):
            count += 1

    print(count)

Python: # Aizu Problem 0185: Goldbach Conjecture II
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

primes = primes2(10**6)
pset = set(primes)

while True:
    n = int(input())
    if n == 0:
        break
    S = 0
    for p in primes:
        if p > n // 2:
            break
        if n - p in pset:
            S += 1
    print(S)

Python: # AOJ 0185 Goldbach's Conjecture II
# Python3 2018.6.20 bal4u

MAX = 1000000
SQRT = 1000     # sqrt(MAX)

prime = [True for i in range(MAX)]
prime[1] = False

def sieve():
	for i in range(3, SQRT, 2):
		if prime[i] is True:
			for j in range(i*i, MAX, i):
				prime[j] = False
sieve()

while True:
	n = int(input())
	if n == 0: break
	i = j = n >> 1
	if (i & 1) == 0:
		i -= 1
		j += 1
	ans = 0
	while i > 0:
		if prime[i] and prime[j]: ans += 1
		i -= 2
		j += 2
	print(ans)

Python: import array
import bisect


def is_prime_number(num):
    limit = int(num ** 0.5)

    for lp in range(3, limit + 1, 2):
        if num % lp == 0:
            return False

    return True


def binary_search(num_list, num):
    left = 0
    right = len(num_list) - 1

    while left <= right:
        mid = (left + right) // 2

        if num_list[mid] == num:
            return True
        elif num_list[mid] < num:
            left = mid + 1
        else:
            right = mid - 1

    return False


LENGTH = 1000000
prime_number_list = array.array("i", [True] * (LENGTH + 1))

prime_number_list[0] = False
prime_number_list[1] = False

for lp in range(4, LENGTH + 1, 2):
    prime_number_list[lp] = False

limit = int((LENGTH + 1) ** 0.5)

for lp in range(3, limit + 1, 2):
    if is_prime_number(lp):
        for lp2 in range(lp * 2, LENGTH + 1, lp):
            prime_number_list[lp2] = False

prime_number_list = array.array("i", [index for index, item in enumerate(prime_number_list) if item])

while True:

    input_num = int(input())

    if input_num == 0:
        break

    count = 0

    array_size = bisect.bisect_left(prime_number_list, input_num // 2)

    for lp in prime_number_list[:array_size + 1]:

        search_num = input_num - lp

        if binary_search(prime_number_list, search_num):
            count += 1

    print(count)