Smarandache prime-digital sequence: Difference between revisions

Smarandache prime-digital sequence en BASIC256
m (→‎Optimised: tidy up)
(Smarandache prime-digital sequence en BASIC256)
Line 320:
100: 33223
</pre>
 
=={{header|BASIC256}}==
{{trans|FreeBASIC}}
<lang freebasic>arraybase 1
dim smar(100)
smar[1] = 2
 
cont = 1
i = 1
 
print 1, 2
while cont < 100
i += 2
if not isPrime(i) then continue while
for j = 1 to length(string(i))
digit = int(mid(string(i),j,1))
if not isPrime(digit) then continue while
next j
cont += 1
smar[cont] = i
if cont = 100 or cont <= 25 then print cont, smar[cont]
end while
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>
{{out}}
<pre>Igual que la entrada de FreeBASIC.</pre>
 
 
=={{header|C}}==
2,130

edits