Problem 56393. Easy Sequences 77: Powers of Fibonacci Numbers
Solution Stats
Problem Comments
-
3 Comments
Test 10 is wrong. I ran your algorithm using java math and obtained:
s=[1021322 1048348 1452207 670027] which is the same figures I obtained using my algorithm. My algorithm passes all the other tests.
Hi David, I have not accounted for Fibonacci of 0 which is 0, which is required in my algorithm. Please try again.
Surprisingly easy once you see a couple of tricks.
Solution Comments
-
2 Comments
I know this solution has a higher Cody score than my previous, but it only takes one line of 75 characters (excluding endline), and I couldn't resist. This problem is THAT simple. It uses only five variables - including inputs and outputs, and all are scalars -- and nothing language specific besides how functions and for loops are defined and mod(), which essentially all languages define or at least support. And, of course, a couple of theorems.
No strings, str2num,regex, or any other tricks to make it seem simpler than it is! See the previous solution for a few comments that help a bit identifying the theorems.
That’s why it’s called “Easy…”
Problem Recent Solvers3
Suggested Problems
-
2730 Solvers
-
104 Solvers
-
Similar Triangles - find the height of the tree
251 Solvers
-
161 Solvers
-
Easy Sequences 4: Eliminate the Days of Confusion
18 Solvers
More from this Author90
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!