Prime numbers p for which the sum of primes less than or equal to p is prime: Difference between revisions
Prime numbers p for which the sum of primes less than or equal to p is prime (view source)
Revision as of 21:09, 10 May 2023
, 1 year agono edit summary
m (Changed "collect(newSeq):" to "collect:" as "newSeq" is no longer needed.) |
No edit summary |
||
Line 136:
1-999: 21
</pre>
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
<syntaxhighlight lang="Delphi">
procedure ShowPrimeLesserSum(Memo: TMemo);
var N,Sum,Cnt: integer;
var S: string;
begin
Cnt:=0;
Sum:=0;
for N:=2 to 1000-1 do
if IsPrime(N) then
begin
Sum:=Sum+N;
if IsPrime(Sum) then
begin
Inc(Cnt);
S:=S+Format('%4d',[N]);
If (Cnt mod 5)=0 then S:=S+CRLF;
end;
end;
Memo.Lines.Add(S);
Memo.Lines.Add('Count='+IntToStr(Cnt));
end;
</syntaxhighlight>
{{out}}
<pre>
2 3 7 13 37
43 281 311 503 541
557 593 619 673 683
733 743 839 881 929
953
Count=21
Elapsed Time: 2.006 ms.
</pre>
=={{header|F_Sharp|F#}}==
|