Skip to content

Commit c574d67

Browse files
Fibonacci and Factorial
1 parent 172453b commit c574d67

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Maths/Factorial.hs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Maths.Factorial where
2+
3+
fac :: Integer -> Integer
4+
fac 0 = 1
5+
fac n = n * fac (n - 1)
6+
7+
main :: IO ()
8+
main = do
9+
print (fac 4)

src/Maths/Fibonacci.hs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Maths.Fibonacci where
2+
3+
fib :: Integer -> Integer
4+
fib 0 = 0
5+
fib 1 = 1
6+
fib n = fib (n-1) + fib (n-2)
7+
8+
main :: IO ()
9+
main = do
10+
print (fib 10)

0 commit comments

Comments
 (0)