Smarandache prime-digital sequence: Difference between revisions

m (Minor edit to C++ code)
Line 1,003:
The 10000th Smarandache prime is: 273322727
</pre>
 
=={{header|Lua}}==
<lang lua>-- FUNCS:
local function T(t) return setmetatable(t, {__index=table}) end
table.firstn = function(t,n) local s=T{} n=n>#t and #t or n for i = 1,n do s[i]=t[i] end return s end
 
-- SIEVE:
local sieve, S = {}, 50000
for i = 2,S do sieve[i]=true end
for i = 2,S do if sieve[i] then for j=i*i,S,i do sieve[j]=nil end end end
 
-- TASKS:
local digs, cans, spds, N = {2,3,5,7}, T{0}, T{}, 100
while #spds < N do
local c = cans:remove(1)
for _,d in ipairs(digs) do cans:insert(c*10+d) end
if sieve[c] then spds:insert(c) end
end
print("1-25 : " .. spds:firstn(25):concat(" "))
print("100th: " .. spds[100])</lang>
{{out}}
<pre>1-25 : 2 3 5 7 23 37 53 73 223 227 233 257 277 337 353 373 523 557 577 727 733 757 773 2237 2273
100th: 33223</pre>
 
=={{header|Pascal}}==
Anonymous user