16 lines
464 B
Plaintext
16 lines
464 B
Plaintext
#MAX=500
|
|
Global Dim P.b(#MAX) : FillMemory(@P(),#MAX,1,#PB_Byte)
|
|
If OpenConsole()=0 : End 1 : EndIf
|
|
For n=2 To Sqr(#MAX)+1 : If P(n) : m=n*n : While m<=#MAX : P(m)=0 : m+n : Wend : EndIf : Next
|
|
|
|
Procedure.i qsum(v.i)
|
|
While v : qs+v%10 : v/10 : Wend
|
|
ProcedureReturn qs
|
|
EndProcedure
|
|
|
|
For i=2 To #MAX
|
|
If P(i) And P(qsum(i)) : c+1 : Print(RSet(Str(i),5)) : If c%10=0 : PrintN("") : EndIf : EndIf
|
|
Next
|
|
PrintN(~"\n\n"+Str(c)+" additive primes below 500.")
|
|
Input()
|