Smarandache prime-digital sequence: Difference between revisions
Content added Content deleted
(Smarandache prime-digital sequence en BASIC256) |
(Smarandache prime-digital sequence en Yabasic) |
||
Line 2,122: | Line 2,122: | ||
The 1,000th SPDS prime is 3273527 |
The 1,000th SPDS prime is 3273527 |
||
</pre> |
</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}}== |
=={{header|zkl}}== |