skip to main
|
skip to sidebar
Haskell Problems Solved..
haskell code.
Friday, February 27, 2009
finding the highest common factor/divisor for two integers in haskell
hcf :: Int -> Int -> Int
--handles all cases of zero
hcf 0 0 = undefined
hcf m 0 = abs m
hcf 0 n = abs n
hcf m n
| m == n = m
| m > n = hcf n (rem m n)
| otherwise = hcf n m
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Blog Archive
▼
2009
(13)
►
June
(3)
▼
February
(10)
Raising a number to the power of another number. e...
finding the highest common factor/divisor for two ...
fibonacci sequence in haskell : not very efficient
Integer square root of a positive integer in haskell
Using recursive addition to multiply in haskell
Finding the factorial in haskell.
finding out how many are equal amongst three numnb...
Finding max of two, three or four in haskell
Finding the number of roots in a quadratic equatio...
Finding the average of three numbers in haskell
No comments:
Post a Comment