Explorar o código

Implement fibonacci function

DricomDragon %!s(int64=5) %!d(string=hai) anos
pai
achega
e0fdc07432
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      t1.hs

+ 3 - 1
t1.hs

@@ -1,4 +1,6 @@
-f n = n * n
+f n = case n of
+	0 -> 1
+	_ -> n * f (n - 1)
 
 main :: IO ()
 main = print ( f 5 )