English
Source / code snippets

Größter gemeinsamer Teiler GGT: Stein´scher Algorithmus

 

p.specht

of/ one the first known Algorithms at all stammt of EUKLID (360 - 280 v. Chr). then went it around the größtmögliche curtail of Brüchen. first plenty later, A.D. 1967 erkannte one further Verbesserungsmöglichkeiten, so z.B. whom Algorithmus of Josef stone (D), the OHNE DIVISIONEN auskommt: Simple Rechtsverschieben the Binärzahl reicht completely from, what The thing ungemein speed. enclosed this Algorithmus (fountain: Symbolisches Program of Prof.em. Donald Knuth, the Algorithmenpapst)
Window Style 1048
Window Title "Stein´scher GGT-Algorithmus"
' (CL) Copyleft 2012-09 P. woodpecker, Wien
Declare w$,a&,b&
Loop:
Cls : print
print " Ganzzahliger Divisor: "; : input w$

if (right$("0000000000"+w$,10)>"2147483647")

    print "Zu big, max: 2147483647"
    waitinput
    goto "Loop"

endif

a& = val(w$)
print " Ganzzahliger Dividende: "; : input w$

if (right$("0000000000"+w$,10)>"2147483647")

    print "Zu big, max: 2147483647"
    waitinput
    goto "Loop"

endif

b& = val(w$)
print
print " Größter gemeinsamer Teiler (GGT) to stone: ";stone(a&,b&)
waitinput
Goto "Loop"

Proc stone

    parameters a&,b&
    declare k&,erg&,t&

    if a&=0:erg&=0:goto "jump":endif

        WhileNot ((a& mod 2) or (b& mod 2))

            a&=a&\2
            b&=b&\2
            inc k&

        endwhile

        if (a& mod 2)

            t&= -1*b&

        else

            t&= a&

        endif

        while t&

            whilenot t& mod 2

                t&=t&\2

            endwhile

            if t&>0

                a&=t&

            else

                b&= -1*t&

            endif

            t&= a&-b&

        endwhile

        erg&=a& * 2^k&
        jump:
        return erg&

    ENDPROC

 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/01/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

650 Views

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