Jump to content

Smarandache prime-digital sequence: Difference between revisions

Smarandache prime-digital sequence en Yabasic
(Smarandache prime-digital sequence en BASIC256)
(Smarandache prime-digital sequence en Yabasic)
Line 2,122:
The 1,000th SPDS prime is 3273527
</pre>
 
=={{header|Yabasic}}==
{{trans|Ring}}
<lang yabasic>num = 0
limit = 26
limit100 = 100
 
print "First 25 Smarandache primes:\n"
for n = 1 to 34000
flag = 0
nStr$ = str$(n)
for x = 1 to len(nStr$)
nx = val(mid$(nStr$,x,1))
if isPrime(n) and isPrime(nx) then
flag = flag + 1
else
break
end if
next
if flag = len(nStr$) then
num = num + 1
if num < limit print "", n, " ";
if num = limit100 print "\n\n100th Smarandache prime: ", n
end if
next n
end
 
sub isPrime(v)
if v < 2 return False
if mod(v, 2) = 0 return v = 2
if mod(v, 3) = 0 return v = 3
d = 5
while d * d <= v
if mod(v, d) = 0 then return False else d = d + 2 : fi
wend
return True
end sub</lang>
{{out}}
<pre>Igual que la entrada de Ring.</pre>
 
 
=={{header|zkl}}==
2,133

edits

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