Talk:Zeckendorf number representation: Difference between revisions

From Rosetta Code
Content added Content deleted
Line 7: Line 7:


:I will modify the task description to specify an algorithm to use that can only give a unique sequence. Thanks for the heads-up. --[[User:Paddy3118|Paddy3118]] 12:08, 11 October 2012 (UTC)
:I will modify the task description to specify an algorithm to use that can only give a unique sequence. Thanks for the heads-up. --[[User:Paddy3118|Paddy3118]] 12:08, 11 October 2012 (UTC)

::Task specific 2 is still ambiguous for the case of ZR(1). The sequences {1} and {1, 1} both satisfy the criterion of the greatest of the sequence being a number less than or equal to the number for conversion, but the greedy rule leads the first to produce ZR(1) = 1 and the second ZR(1) = 10. —[[User:Sonia|Sonia]] 17:51, 11 October 2012 (UTC)


==Perl 6, wrong fib sequence==
==Perl 6, wrong fib sequence==

Revision as of 17:51, 11 October 2012

Consensus on the sequence

Googling around, there seems to be a lack of consensus on the sequence of Fibonacci numbers used and how the sequence is indexed. If you include both F(1) = 1 and F(2) = 1, then the representation 1 is not unique. Similarly, if you include F(0) = 0, then the representation of 0 is not unique.

Mathworld's page on Zeckendorf's theorem mentions that it applies to {F-1}, that is, the Fibonacci sequence with one of the 1s removed, and presumably without the 0. —Sonia 22:39, 10 October 2012 (UTC)

There simply can't be two 1s, otherwise a lot of numbers won't have unique summation: anything in for form of big_fib + 3 can also be written as big_fib + 2 + 1 (that's using the first one; the second one would be next to 2, if that makes sense -- well if it doesn't, it sort of proves the point also.) --Ledrug 01:27, 11 October 2012 (UTC)
I will modify the task description to specify an algorithm to use that can only give a unique sequence. Thanks for the heads-up. --Paddy3118 12:08, 11 October 2012 (UTC)
Task specific 2 is still ambiguous for the case of ZR(1). The sequences {1} and {1, 1} both satisfy the criterion of the greatest of the sequence being a number less than or equal to the number for conversion, but the greedy rule leads the first to produce ZR(1) = 1 and the second ZR(1) = 10. —Sonia 17:51, 11 October 2012 (UTC)

Perl 6, wrong fib sequence

Could there also be a submission for Perl6 that used the sequence starting 1, 1, 2, ... The present example could be put second as an alternative, with the present description of how it differs from the task description if you like. --Paddy3118 12:14, 11 October 2012 (UTC)

If you're going to mandate the 1,1 sequence, then there's no point in having alternatives. On the other hand, you could mandate that the initial sequence must be specified by the user, perhaps defaulting to 1,1. But 0,1 and 1,2 are also sane, the latter because it eliminates the useless 0 on the end of every result, and the former because that's also a common way to define Fibonacci sequences. The 1,2 version is also appropriate under the notion that you're just using all the positive Fibonacci numbers in order, not the sequence itself. But as my grandmother-in-law used to say, this is all a tempest in a teabag. :-) --TimToady