Your code will fail with nested loops. You need to find a more efficient way to compute the answer. Nobody should give you any formula, that would be giving the solution.
This kata can be solved without applying special formulas from Numberphile video. It is just for educational purposes. Try to come up with something "easier"
Your answer is running in O(n^2) time! The outer for loop is the first "n", but your call to Array.indexOf() does another linear search through the array for a second "n" search, increasing the time by quite a lot!
I recommend searching online for some of the Kata tags for clues :)
Your code will fail with nested loops. You need to find a more efficient way to compute the answer. Nobody should give you any formula, that would be giving the solution.
This kata can be solved without applying special formulas from Numberphile video. It is just for educational purposes. Try to come up with something "easier"
Even numbers do not need special handling.
(message deleted cause I'm not sure it's right...)
hahah and i think why pop and shift doesnt work :D
Your answer is running in O(n^2) time! The outer for loop is the first "n", but your call to Array.indexOf() does another linear search through the array for a second "n" search, increasing the time by quite a lot!
I recommend searching online for some of the Kata tags for clues :)