Long primes: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: added syntax colouring the hard way) |
No edit summary |
||
Line 2,418: | Line 2,418: | ||
% 8,564,024 inferences, 0.991 CPU in 1.040 seconds (95% CPU, 8641390 Lips) |
% 8,564,024 inferences, 0.991 CPU in 1.040 seconds (95% CPU, 8641390 Lips) |
||
true. |
true. |
||
</pre> |
|||
=={{header|PureBasic}}== |
|||
<lang PureBasic>#MAX=64000 |
|||
If OpenConsole()=0 : End 1 : EndIf |
|||
Dim p.b(#MAX) : FillMemory(@p(),#MAX,#True,#PB_Byte) |
|||
For n=2 To Int(Sqr(#MAX))+1 : If p(n) : m=n*n : While m<=#MAX : p(m)=#False : m+n : Wend : EndIf : Next |
|||
Procedure.i periodic(v.i) |
|||
r=1 : Repeat : r=(r*10)%v : c+1 : If r<=1 : ProcedureReturn c : EndIf : ForEver |
|||
EndProcedure |
|||
n=500 |
|||
PrintN(LSet("_",15,"_")+"Long primes upto "+Str(n)+LSet("_",15,"_")) |
|||
For i=3 To 500 Step 2 |
|||
If p(i) And (i-1)=periodic(i) |
|||
Print(RSet(Str(i),5)) : c+1 : If c%10=0 : PrintN("") : EndIf |
|||
EndIf |
|||
Next |
|||
PrintN(~"\n") |
|||
PrintN("The number of long primes up to:") |
|||
PrintN(RSet(Str(n),8)+" is "+Str(c)) : n+n |
|||
For i=501 To #MAX+1 Step 2 |
|||
If p(i) And (i-1)=periodic(i) : c+1 : EndIf |
|||
If i>n : PrintN(RSet(Str(n),8)+" is "+Str(c)) : n+n : EndIf |
|||
Next |
|||
Input()</lang> |
|||
{{out}} |
|||
<pre>_______________Long primes upto 500_______________ |
|||
7 17 19 23 29 47 59 61 97 109 |
|||
113 131 149 167 179 181 193 223 229 233 |
|||
257 263 269 313 337 367 379 383 389 419 |
|||
433 461 487 491 499 |
|||
The number of long primes up to: |
|||
500 is 35 |
|||
1000 is 60 |
|||
2000 is 116 |
|||
4000 is 218 |
|||
8000 is 390 |
|||
16000 is 716 |
|||
32000 is 1300 |
|||
64000 is 2430 |
|||
</pre> |
</pre> |
||