English
Source / code snippets

to charge Primzahl

 

Jac
de
Lad
Folgender of me entwickelter and of my opinion to right effective code accounts in Parcival The Primzahlen (here The profanisierte Variante):
CompileMarkSeparation
proc Primzahl

    Parameters z&
    declare f&,n&,x%,y%

    if z&>0

        Select z&

            CaseOf 3,2,7,5

            Return 1

            CaseOf 1

            Return 0
            Otherwise
            casenot z& MOD 2:Return 0
            f&=1
            n&=Int(Sqrt(z&))
            Inc x%

            while (f&<n&) & x%

                Inc f&,2
                casenot z& MOD f&:Dec x%
                y%=Not(y%)

            endwhile

            Return x%

        EndSelect

    else

        Return -1 Ungültige Zahl

    endif

endproc


knows someone a better, effektiveren code?

Jac
 
Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
06/16/08  
 



https://www.maths.de/mde/information/landkarte/numbers/primzahlen.html
How can systematic any Primzahlen find?

the bekannteste take action is the Sieb the Eratosthenes, benannt to the greek Mathematiker Eratosthenes of Kyrene, the in the third vorchristlichen centenary lived.
here his suggestion, circa any Primzahlen to find:

write The natural numbers, beginnend with 2, one after another there:
2, 3, 4, 5, 6, 7, 8, 9, ...
Streiche any real Vielfachen of 2, means 4, 6, ...:
2, 3, 4, 5, 6, 7, 8, 9, ...
Streiche any real Vielfachen of 3, means 6, 9, ... (The 6 is already in the first round ausgeschieden): 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ...

an so on: as nächstes go The Vielfachen of 5 gestrichen, then The of 7 etc. Accurate: in the k-ten Passage streiche The Vielfachen the k-ten number, The by then yet ,,survive hat; this is then The k-th Primzahl.

The Begründung for success the Verfahrens is easy: Each not-Primzahl n has a real Primteiler p, and so becomes n with the To p gehörigen Streichungsrunde gestrichen.
 
06/16/08  
 




Jac
de
Lad
No, me GEHTS therefore, whether a number z& a Primzahl is. The function ought to means sooner IsPrim hot.
 
Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
06/16/08  
 



https://www.hackerboard.de/thread.php?threadid=4852

CompileMarkSeparation
int isprimzahl(int value)

{

    int tempo = 0;
    int testa = 0;

    if (value == 0)

        return -1;
        for(tempo = 2; tempo < value; tempo++)

        {

            testa = value % tempo;

            if ( (testa == 0) && (tempo != value) && (tempo != 1))

                return 0;

            }

            return 1;

        r=#0000FF>}



Mach time to XProfan...
 
06/16/08  
 




Jac
de
Lad
What is the Difference between != and ==?
 
Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
06/16/08  
 



!= is mismatched (<>), == is same (=)

Lol I see strain one should only a row change and XPSE would from it XProfan make muhhaa...
 
06/16/08  
 



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

8.169 Views

Untitledvor 0 min.
p.specht10/17/18
Jörg Sellmeyer05/18/18
Michael W.03/27/16
Paul Glatz04/10/13
More...

Themeninformationen

this Topic has 2 subscriber:

iF (3x)
Jac de Lad (3x)


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