Run Code

API

Code Wall

Users

Misc

Feedback

Login

Theme

Privacy

Patreon
Fibonacci proof
{ So, here we are falala, tralala, and I pull from my bundle of tricks a mathish problem. Counting is 'math'...ish, isn't it? This is from @jammestanton who asks us to make the following observation about the Fibonacci numbers, which we found from our dear sweetie, Rosalind have to do with bunnies and what bunnies like to do. So, we have the Fibonacci number series: 1,1,2,3,5,8,... So let f n be the nth Fibonacci number so f 1 == 1, f 2 == 1, etc. } f :: Integer > Integer f 0 = 0 f 1 = 1 f n = (f $ n  2) + (f $ n  1)  Now, let g n be the count of the Fibonacci numbers < n (so, g 3 == 3) g :: Integer > Integer g n = foldl (\x _ > x + 1) 0 . takeWhile (< n) $ map f [1..]  NOW, let h n be the count of the number of g's that are < n h :: Integer > Integer h n = foldl (\x _ > x + 1) 0 . takeWhile (< n) $ map g [1..]  James asks: What do you notice unique to Fibonacci numbers? main = print $ map f [1..10] == map h [1..10]
run

edit

history

help
0
Please
log in
to post a comment.
Quicksort in Haskell
Hanoi solver
folder
Factors of a number, prime numbers
Is Preorder BST
Haskell Fibonacci Numbers
(‿‿)
Knight Journey
Bruteforce IEEE Floating Point Numbers
Métodos simples
Please log in to post a comment.