Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Alternatively,

     fibonacci n = (map fst $ iterate (\(a,b) -> (b,a+b)) (0,1)) !! n


I think gamegoblin's was prettier.


Got a really short one!

     fib a b = a : fib b (a+b)
     fibn = (!!) (fib 0 1)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: