瀏覽代碼

Implement fibonacci function

DricomDragon 5 年之前
父節點
當前提交
e0fdc07432
共有 1 個文件被更改,包括 3 次插入1 次删除
  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 )