Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Added to JS, Python, and Java.
The formula is not accurate for n > 71. Hence, this solution won't work for even trivial values.
can you tell me what do you mean by the #2 and #3 flaws? I wanna know the bottlenecks they could cause us?
Fun! But it's not quite right! For example your version of productFib(24) gives (4,6,true), when 4 and 6 aren't fibonacci numbers. Other examples are 60, 77, 135, 160, and 198. These are the product of two numbers that very closely have a golden ratio between them, but they don't appear in the fibonacci sequence.
See https://en.wikipedia.org/wiki/Fibonacci_number#Closed-form_expression
phi=(sqrt(5)+1)/2 = 2/(sqrt(5)-1) ~= F(n+1)/F(n) for large n. So F(n) ~= F(n+1)/phi, where by ~= I mean "approximately equals". It turns out the round function can be used since F(n+1)/phi will be within 0.5 of F(n).
I never thought to use an array in a for loop before, what an intiguing use.
i've added
==
in the description's JS code blockswhy sqrt(5)?
Good point, calling the object "arr" confused me.
It is definetely not a byproduct of the kata requiring the next highest pair. The reason people haven't been using this solution is because most don't know about it.
I know this is old, but thanks for sharing! Very interesting.
I'm forced to reply to the wrong person, but here we go
Brute force generally means to generate every possible combination until you find one that gives you an answer. In this case, it refers to starting from the bottom of the fibonacci sequence and progressing through it until you arrive at a stopping case (fib(n) * fib(n+1) >= prod).
This comment is hidden because it contains spoiler information about the solution
Hey! I'm new here. Can you please explain what you mean by brute force algorithm?
Thank you for your suggestion!
I saw your solution, but it was not actually working as I expected, so I decided to solve it like this:
https://www.codewars.com/kata/reviews/554398d646002df491000183/groups/5dc2fa1a83a99000015a24ba
Loading more items...