Problem 56393. Easy Sequences 77: Powers of Fibonacci Numbers
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.
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
Create block matrix of integers (j+k-1) - Part II
More from this Author101
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!