Euklid
This commit is contained in:
parent
7561d34d8d
commit
2b1d879eeb
3 changed files with 17 additions and 0 deletions
13
Euklid.fs
Normal file
13
Euklid.fs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
module Euklid
|
||||
|
||||
open System
|
||||
|
||||
let rec euklid a b =
|
||||
if b = 0 then a
|
||||
else euklid b (a % b)
|
||||
|
||||
let rec erwEuklid a b =
|
||||
if b = 0 then (a, 1, 0)
|
||||
else
|
||||
let (d, x, y) = erwEuklid b (a % b)
|
||||
(d, y, x - (a / b) * y)
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="OtherFile.fs" />
|
||||
<Compile Include="BetterThanRacket.fs" />
|
||||
<Compile Include="Euklid.fs" />
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -103,4 +103,7 @@ let main argv =
|
|||
|
||||
printfn "%b" (BetterThanRacket.BinaryTreeHausübung.BinaryTreeContains 56 BinaryTreeHausübung.smallTree)
|
||||
|
||||
printfn "%A" (Euklid.euklid 128 36)
|
||||
printfn "%A" (Euklid.erwEuklid 128 36)
|
||||
|
||||
0 // return an integer exit code
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue