EnableExplicit DisableDebugger Define StartTime.i=ElapsedMilliseconds() Procedure.b IsPrime(n.i) Define i.i=5 If n<2 : ProcedureReturn #False : EndIf If n%2=0 : ProcedureReturn Bool(n=2) : EndIf If n%3=0 : ProcedureReturn Bool(n=3) : EndIf While i*i<=n If n%i=0 : ProcedureReturn #False : EndIf i+2 If n%i=0 : ProcedureReturn #False : EndIf i+4 Wend ProcedureReturn #True EndProcedure If OpenConsole("Extensible prime generator") Define c.i=0, n.i=2 Print("First twenty: ") While c<20 If IsPrime(n) Print(Str(n)+" ") c+1 EndIf n+1 Wend Print(~"\nBetween 100 and 150: ") For n=100 To 150 If IsPrime(n) Print(Str(n)+" ") EndIf Next Print(~"\nNumber beween 7'700 and 8'000: ") c=0 For n=7700 To 8000 c+IsPrime(n) Next Print(Str(c)) Print(~"\n10'000th prime: ") c=0 : n=1 While c<10000 n+1 c+IsPrime(n) Wend Print(Str(n)) EndIf Print(~"\nRuntime milliseconds: "+ Str(ElapsedMilliseconds()-StartTime)) Input()