|  |  | 
|  | 
|  | 
|  p.specht
 
 
  | | 
 'PrimTurbo, the Turbo-Primzahlensuchprogramm of @Johnathan, here without Assemblercode
'finds any Primzahlen of 2 - z.B. 100.000 within 12,6 sec (Interpreter!)
Window Title "Jonathans PRIM-TURBO"
Cls
Declare Primeln&[], PrimIndex&, MaxPrimel&, ActPrimel&, StartZeit&, PrimCount&, spending%, JN$
Print "Primzahlen find To: ";
Input MaxPrimel&
Primeln&[MaxPrimel&] = 0
Print ""
Print "Primzahlen go sought..."
StartZeit& = &gettickcount
WhileLoop 4, MaxPrimel&, 2
    Primeln&[&loop] = 1
EndWhile
WhileLoop 3, (MaxPrimel& \ 3) + 1
    ActPrimel& = &loop
    If Primeln&[ActPrimel&] = 0
        WhileLoop 3, (MaxPrimel& \ ActPrimel&), 2
            Primeln&[&loop * ActPrimel&] = 1
        EndWhile
    EndIf
EndWhile
Print ""
Print "Suchen completed."
Print "Benötigte Time: " + @Str $((&gettickcount - StartZeit&) / 1000) + " sec."
Print ""
Print "Primzahlen count (J/n)? ";
Input JN$
If @Upper $(JN$) = "J"
    Print ""
    Print "Primzahlen go counted..."
    PrimCount& = 0
    WhileLoop 2, MaxPrimel&
        If Primeln&[&loop] = 0
            Inc PrimCount&
        EndIf
    EndWhile
    Print ""
    Print "Gefundene Primzahlen: " + @Str $(PrimCount&)
EndIf
Print ""
Print "Ausgeben (0 = not ausg.; 1 = in the Window ausgeben;"
Print "2 = In File ausgeben; 3 = both)? ";
Input spending%
If (spending% Mod 2)
    Print ""
    Print "Ausgabe:"
    WhileLoop 2, MaxPrimel&
        If Primeln&[&loop] = 0
            Print &loop,
            if %csrlin>25:cls
            endif
        EndIf
    EndWhile
EndIf
If (spending% \ 2)
    Print ""
    Print "Dateiausgabe..."
    Assign #1, "Primzahlen.txt"
    ReWrite #1
    WhileLoop 2, MaxPrimel&
        If Primeln&[&loop] = 0
            Print #1, &loop
        EndIf
    EndWhile
    Close #1
EndIf
WaitInput
End
 | 
 | 
|  | 
|  | | Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 04/18/21  ▲ | 
 | 
|  | 
| 
 
 
 |