Skip to content

Instantly share code, notes, and snippets.

@aspnetde
Created June 20, 2017 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspnetde/277df06392d1a656bc24c117f04ca028 to your computer and use it in GitHub Desktop.
Save aspnetde/277df06392d1a656bc24c117f04ca028 to your computer and use it in GitHub Desktop.
Erweiterter Euklidischer Algorithmus
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