Skip to content

Commit ee361ab

Browse files
committed
[exercise] 6.4
1 parent 06a8159 commit ee361ab

File tree

1 file changed

+7
-0
lines changed
  • chapter06-Recursive-functions

1 file changed

+7
-0
lines changed

chapter06-Recursive-functions/4.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
euclid :: Int -> Int -> Int
2+
euclid 0 n = n
3+
euclid n 0 = n
4+
euclid m n | m < n = euclid m (n - m)
5+
| otherwise = euclid (m - n) n
6+
7+
{- The algorithm is slightly modified to process corner cases. -}

0 commit comments

Comments
 (0)