Smarandache prime-digital sequence: Difference between revisions

no edit summary
(added Arturo)
No edit summary
Line 540:
Largest SPDS prime less than 1,000,000,000: 777,777,773
</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
Uses the [[Extensible_prime_generator#Delphi|Delphi Prime-Generator Object]]
 
<syntaxhighlight lang="Delphi">
procedure ShowSmarandachePrimes(Memo: TMemo);
{Show primes where all digits are also prime}
var Sieve: TPrimeSieve;
var I,J,P,Count: integer;
var S: string;
 
 
function AllDigitsPrime(N: integer): boolean;
{Test all digits on N to see if they are prime}
var I,Count: integer;
var IA: TIntegerDynArray;
begin
Result:=False;
GetDigits(N,IA);
for I:=0 to High(IA) do
if not Sieve.Flags[IA[I]] then exit;
Result:=True;
end;
 
 
begin
Sieve:=TPrimeSieve.Create;
try
{Build 1 million primes}
Sieve.Intialize(1000000);
Count:=0;
{Test if all digits of the number are prime}
for I:=0 to Sieve.PrimeCount-1 do
begin
P:=Sieve.Primes[I];
if AllDigitsPrime(P) then
begin
Inc(Count);
if Count<=25 then Memo.Lines.Add(IntToStr(Count)+' - '+IntToStr(P));
if Count=100 then
begin
Memo.Lines.Add('100th = '+IntToStr(P));
break;
end;
end;
end;
finally Sieve.Free; end;
end;
 
 
</syntaxhighlight>
{{out}}
<pre>
1 - 2
2 - 3
3 - 5
4 - 7
5 - 23
6 - 37
7 - 53
8 - 73
9 - 223
10 - 227
11 - 233
12 - 257
13 - 277
14 - 337
15 - 353
16 - 373
17 - 523
18 - 557
19 - 577
20 - 727
21 - 733
22 - 757
23 - 773
24 - 2237
25 - 2273
100th = 33223
Elapsed Time: 150.037 ms.
</pre>
 
 
=={{header|F_Sharp|F#}}==
465

edits