Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hello Everyone.
From :
The question is : Need help creating a Program Function for "Zeckendorf Representation for Natural Number (2017) with Lucas Numbers ?
Thanks in advance for your time and help.
Best Regards.
Solved! Go to Solution.
Here you are. The problem was that the first two Lucas numbers are not in sequence and so had to be treated differently to return the correct index for the first two sequence elements. This is solved now in a different way and the routine works OK as long as the initial value is >=0
Isn't that a quite easy task?
Or am I missing the point?
I'm very, very happy with your answer, Werner.
. I greatly appreciate your time and help.
Best Regards.
Here's a slightly modified version which returns the numbers themselves, too.
Thanks again, Werner. I very,very
. And I guess your Program Function could apply for : "Zeckendorf representation for certain Natural number with both of Fibonacci numbers and Lucas numbers :
But I guess : "Zeckendorf representation for certain Natural number with Fibonacci numbers" would choose F[2 instead of F[1 ???
So could we modify the Program Function above suit with Zeckendorf representation and apply to both of Fibonacci numbers and Lucas numbers ?
Best Regards.
Loi
Here you are. The problem was that the first two Lucas numbers are not in sequence and so had to be treated differently to return the correct index for the first two sequence elements. This is solved now in a different way and the routine works OK as long as the initial value is >=0
M...o...r...e than
...
Best Regards.
and the routine works OK as long as the initial value is >=0 ?? initial value must be ~(8) , because :
Best Regards.
Yes, the indices are correct only if we use a sequence where a unique representation with a sum of sequence numbers exists and each number only appears at max once.
You may change the routine by going through the array at the end of the routine and if initial was > 1 then exchange EVERY index 0 for index 1 and vice versa.
As the routine is now only the first index is treated that way because its assumed that every number occurs at most one times.