Created
June 20, 2017 21:54
-
-
Save aspnetde/277df06392d1a656bc24c117f04ca028 to your computer and use it in GitHub Desktop.
Erweiterter Euklidischer Algorithmus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec ggT a b = | |
let r = a % b | |
if r = 0 || r = b then | |
b, 0, 1 | |
else | |
let q = a / b | |
let g, s, t = ggT b r | |
g, t, s - q * t | |
let run a b = | |
let g, s, t = ggT a b | |
let checksum = a * s + b * t | |
printfn "Der ggT von a := %i und b := %i lautet g := %i. Die Bézout-Koeffizienten lauten s := %i und t := %i: %i*%i + %i*%i = %i" a b g s t a s b t checksum | |
run 45 81 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment