31 lines
536 B
Plaintext
31 lines
536 B
Plaintext
#arraybase 1
|
|
print "The first 100 G numbers are:"
|
|
|
|
col = 1
|
|
for n = 4 to 202 step 2
|
|
print rjust(string(g(n)), 4);
|
|
if col mod 10 = 0 then print
|
|
col += 1
|
|
next n
|
|
|
|
print : print "G(1000000) = "; g(1000000)
|
|
end
|
|
|
|
function isPrime(v)
|
|
if v <= 1 then return False
|
|
for i = 2 to int(sqrt(v))
|
|
if v mod i = 0 then return False
|
|
next i
|
|
return True
|
|
end function
|
|
|
|
function g(n)
|
|
cont = 0
|
|
if n mod 2 = 0 then
|
|
for i = 2 to (1/2) * n
|
|
if isPrime(i) = 1 and isPrime(n - i) = 1 then cont += 1
|
|
next i
|
|
end if
|
|
return cont
|
|
end function
|