Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Additive-primes/PureBasic/additive-primes.basic
Normal file
15
Task/Additive-primes/PureBasic/additive-primes.basic
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue