9 lines
158 B
Haskell
9 lines
158 B
Haskell
|
module Power1 where
|
||
|
|
||
|
power2 :: Int -> Int -> Int
|
||
|
|
||
|
power1 _ 0 = 1
|
||
|
power1 n t
|
||
|
| even t = power2 (n * n) (div t 2)
|
||
|
| otherwise = n * power2 (n * n) (div t 2)
|