Browse Source

Merge branch 'exo1'

DricomDragon 5 years ago
parent
commit
573d661c54
1 changed files with 10 additions and 0 deletions
  1. 10 0
      mypower.hs

+ 10 - 0
mypower.hs

@@ -0,0 +1,10 @@
+e1 x n = case n of
+	0 -> 1
+	_ -> x * e1 x (n - 1)
+
+e2 x n =
+	if n == 0
+		then 1
+		else if even n
+			then e2 (x * x) (div n 2)
+			else x * e2 (x * x) (div n 2)