Safe and Sophie Germain primes: Difference between revisions

Content added Content deleted
(add FreeBASIC)
Line 32: Line 32:
1481 1499
1481 1499
</pre>
</pre>

=={{header|FreeBASIC}}==
<lang freebasic>function isprime(n as integer) as boolean
if n < 2 then return false
if n < 4 then return true
if n mod 2 = 0 then return false
dim as uinteger i = 1
while i*i<=n
i+=2
if n mod i = 0 then return false
wend
return true
end function

function is_sg( n as integer ) as boolean
if not isprime(n) then return false
return isprime(2*n+1)
end function

dim as uinteger c = 1, i = 1
print "2 ";
while c<50
i+=2
if is_sg(i) then
print i;" ";
c+=1
if c mod 10 = 0 then print
end if
wend</lang>
{{out}}<pre>2 3 5 11 23 29 41 53 83 89
113 131 173 179 191 233 239 251 281 293
359 419 431 443 491 509 593 641 653 659
683 719 743 761 809 911 953 1013 1019 1031
1049 1103 1223 1229 1289 1409 1439 1451 1481 1499
</pre>



=={{header|jq}}==
=={{header|jq}}==