Jump to content

Concatenate two primes is also prime: Difference between revisions

Concatenate two primes is also prime en BASIC256
(Concatenate two primes is also prime en Yabasic)
(Concatenate two primes is also prime en BASIC256)
Line 314:
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
<lang BASIC256>c = 0
for p1 = 2 to 99
if not isPrime(p1) then continue for
for p2 = 2 to 99
if not isPrime(p2) then continue for
cat = rjust(string(p1),2) + rjust(string(p2),2)
if isPrime(cat) then
c += 1
print p1; "|"; p2; " ";
if c mod 10 = 0 then print
end if
next p2
next p1
end
 
function isPrime(v)
if v < 2 then return False
if v mod 2 = 0 then return v = 2
if v mod 3 = 0 then return v = 3
d = 5
while d * d <= v
if v mod d = 0 then return False else d += 2
end while
return True
end function</lang>
 
==={{header|FreeBASIC}}===
2,133

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.