Ludic numbers: Difference between revisions

Content added Content deleted
No edit summary
Line 3,299: Line 3,299:
221, 223, 227
221, 223, 227
233, 235, 239
233, 235, 239
</pre>

=={{header|PureBasic}}==
<lang PureBasic>EnableExplicit
If Not OpenConsole() : End 1 : EndIf

#NMAX=25000

Dim ludic.b(#NMAX)
FillMemory(@ludic(0),SizeOf(Byte)*#NMAX,#True,#PB_Byte)

Define.i i,j,n,c1,c2
Define r1$,r2$,r3$,r4$

For i=2 To Int(#NMAX/2)
If ludic(i)
n=0
For j=i+1 To #NMAX
If ludic(j) : n+1 : EndIf
If n=i : ludic(j)=#False : n=0 : EndIf
Next j
EndIf
Next i

n=0 : c1=0 : c2=0
For i=1 To #NMAX
If ludic(i) And n<25 : n+1 : r1$+Str(i)+" " : EndIf
If i<=1000 : c1+Bool(ludic(i)) : EndIf
c2+Bool(ludic(i))
If c2>=2000 And c2<=2005 And ludic(i) : r3$+Str(i)+" " : EndIf
If i<243 And ludic(i) And ludic(i+2) And ludic(i+6)
r4$+"["+Str(i)+" "+Str(i+2)+" "+Str(i+6)+"] "
EndIf
Next
r2$=Str(c1)

PrintN("First 25 Ludic numbers: " +r1$)
PrintN("Ludic numbers below 1000: " +r2$)
PrintN("Ludic numbers 2000 to 2005: " +r3$)
PrintN("Ludic Triplets below 250: " +r4$)
Input()
End</lang>
{{out}}
<pre>First 25 Ludic numbers: 1 2 3 5 7 11 13 17 23 25 29 37 41 43 47 53 61 67 71 77 83 89 91 97 107
Ludic numbers below 1000: 142
Ludic numbers 2000 to 2005: 21475 21481 21487 21493 21503 21511
Ludic Triplets below 250: [1 3 7] [5 7 11] [11 13 17] [23 25 29] [41 43 47] [173 175 179] [221 223 227] [233 235 239]
</pre>
</pre>