Created
December 8, 2014 15:02
-
-
Save trhura/5c6cd143b221022133f1 to your computer and use it in GitHub Desktop.
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
-- Assuming a and b are not negative | |
multiply a 0 = 0 | |
multiply a 1 = a | |
multiply a b = a + multiply a (b-1) | |
-- Assuming e is not negative | |
power b 0 = 1 | |
power b 1 = b | |
power b e = multiply b $ power b (e-1) -- aka multiply b (power b e-1) | |
main = do | |
print $ power 2 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment