Extra primes: Difference between revisions
Content added Content deleted
m (→{{header|Free Pascal}}: Free Pascal as sub category of Pascal) |
m (→{{header|Free Pascal}}: now with crossing 10th order of magnitude like in Raku) |
||
Line 1,990: | Line 1,990: | ||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
==={{header|Free Pascal}}=== |
==={{header|Free Pascal}}=== |
||
using simple circular buffer for last n solutions.With crossing 10th order of magnitude like in Raku. |
|||
<syntaxhighlight lang="pascal"> |
|||
program SpecialPrimes; |
<syntaxhighlight lang="pascal">program SpecialPrimes; |
||
// modified smarandache |
// modified smarandache |
||
{$IFDEF FPC}{$MODE DELPHI}{$OPTIMIZATION ON,ALL}{$ENDIF} |
{$IFDEF FPC}{$MODE DELPHI}{$OPTIMIZATION ON,ALL}{$ENDIF} |
||
Line 2,001: | Line 2,001: | ||
var |
var |
||
//circular buffer |
|||
Last64 : array[0..63] of Uint64; |
Last64 : array[0..63] of Uint64; |
||
cnt,Limit : NativeUint; |
cnt,Limit : NativeUint; |
||
Line 2,010: | Line 2,010: | ||
idx: Int32; |
idx: Int32; |
||
begin |
begin |
||
idx := LastIdx-i |
idx := LastIdx-i; |
||
If idx < Low(Last64) then |
|||
idx += High(Last64); |
idx += High(Last64)+1; |
||
For i := i downto 1 do |
For i := i downto 1 do |
||
begin |
begin |
||
Line 2,081: | Line 2,081: | ||
end |
end |
||
else |
else |
||
IF n > |
IF n > Limit then |
||
Begin |
Begin |
||
OutLast(7); |
OutLast(7); |
||
Line 2,128: | Line 2,128: | ||
inc(LastIdx); |
inc(LastIdx); |
||
OutLast(7); |
OutLast(7); |
||
writeln('count: ',cnt); |
|||
end.</syntaxhighlight> |
end.</syntaxhighlight> |
||
{{out|@TIO.RUN}} |
{{out|@TIO.RUN}} |
||
Line 2,135: | Line 2,136: | ||
2777, 3253, 3257, 3323, 3527, 3727, 5233, 5237, 5273, 5323, |
2777, 3253, 3257, 3323, 3527, 3727, 5233, 5237, 5273, 5323, |
||
5527, 7237, 7253, 7523, 7723, 7727, |
5527, 7237, 7253, 7523, 7723, 7727, |
||
75577 75773 77377 77557 77573 77773 222337 |
|||
772573 773273 773723 775237 775273 777277 2222333 |
|||
7775737 7775753 7777337 7777537 7777573 7777753 22222223 |
|||
77755523 77757257 77757523 77773277 77773723 77777327 222222227 |
|||
777775373 777775553 777775577 777777227 777777577 777777773 2222222377 |
|||
7777772773 7777773257 7777773277 7777775273 7777777237 7777777327 22222222223 |
|||
77777757773 77777773537 77777773757 77777775553 77777777533 77777777573 {{77777272733 63 places before last}} |
|||
count: 107308 |
|||
Real time: 46.241 s CPU share: 99.38 % |
Real time: 46.241 s CPU share: 99.38 % |
||
@home: Real time: 8.615 s maybe much faster div ( Ryzen 5600G 4.4 Ghz vs Xeon 2.3 Ghz) |
@home: Real time: 8.615 s maybe much faster div ( Ryzen 5600G 4.4 Ghz vs Xeon 2.3 Ghz) |