I have a Haskell function that's up and running, but it's doing the wrong thing.
It's supposed to output a Fibonacci sequence up to the maximum number specified.
Like this:
fibonacciSequence 86
1 1 2 3 5 8 13 21 33 54
My code is currently outputting the first 10 numbers in a Fibonacci sequence instead of a Fibonacci sequence from 1 to 10.
It's outputting 1 1 2 3 5 8 13 21 33 54, but it should be 1,1,2,3,5,8.
fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n - 2)
---print (fib n)
fibList n = map fib[1..n]
main =
do
putStrLn "The fibonacci series from 1 to n is:"
print (fibList 10)
Any help would be greatly appreciated. Thanks!