Substring primes: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
No edit summary |
||
Line 415: | Line 415: | ||
373 |
373 |
||
</pre> |
</pre> |
||
=={{header|Delphi}}== |
|||
{{works with|Delphi|6.0}} |
|||
{{libheader|SysUtils,StdCtrls}} |
|||
<syntaxhighlight lang="Delphi"> |
|||
function IsSubstringPrime(N: integer): boolean; |
|||
begin |
|||
if not IsPrime(N) then Result:=False |
|||
else if n < 10 then Result:=True |
|||
else if not IsPrime(N mod 100) then Result:=False |
|||
else if not IsPrime(N mod 10) then Result:=False |
|||
else if not IsPrime(N div 10) then Result:=False |
|||
else if n < 100 then Result:=True |
|||
else if not IsPrime(N div 100) then Result:=False |
|||
else if not IsPrime((N mod 100) div 10) then Result:=False |
|||
else Result:=True; |
|||
end; |
|||
procedure ShowSubtringPrimes(Memo: TMemo); |
|||
var N: integer; |
|||
begin |
|||
for N:=2 to 500-1 do |
|||
if IsSubstringPrime(N) then Memo.Lines.Add(IntToStr(N)); |
|||
end; |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
2 |
|||
3 |
|||
5 |
|||
7 |
|||
23 |
|||
37 |
|||
53 |
|||
73 |
|||
373 |
|||
Elapsed Time: 8.708 ms. |
|||
</pre> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |