English
Source / code snippets

Primzahlen detect: "Jonathans PrimTurbo"-Algorithmus

 

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  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

601 Views

Untitledvor 0 min.
Erhard Wirth06/14/24
p.specht07/31/22
N.Art08/01/21
Ernst07/21/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie