Just as numbers can be represented in a positional notation as sums of multiples of the powers of ten (decimal) or two (binary); all the positive integers can be represented as the sum of one or zero times the distinct members of the Fibonacci series.

Recall that the first six distinct Fibonacci numbers are: 1, 2, 3, 5, 8, 13.

The decimal number eleven can be written as 0*13 + 1*8 + 0*5 + 1*3 + 0*2 + 0*1 or 010100 in positional notation where the columns represent multiplication by a particular member of the sequence. Leading zeroes are dropped so that 11 decimal becomes 10100.

10100 is not the only way to make 11 from the Fibonacci numbers however; 0*13 + 1*8 + 0*5 + 0*3 + 1*2 + 1*1 or 010011 would also represent decimal 11. For a true Zeckendorf number there is the added restriction that no two consecutive Fibonacci numbers can be used which leads to the former unique solution.



Task

Generate and show here a table of the Zeckendorf number representations of the decimal numbers zero to twenty, in order.

The intention in this task to find the Zeckendorf form of an arbitrary integer. The Zeckendorf form can be iterated by some bit twiddling rather than calculating each value separately but leave that to another separate task.



Also see

   OEIS A014417   for the the sequence of required results.
   Brown's Criterion - Numberphile


Related task

   Fibonacci sequence


PROC Encode(INT x CHAR ARRAY s)
  INT ARRAY fib(22)=
    [1 2 3 5 8 13 21 34 55 89 144 233 377 610
    987 1597 2584 4181 6765 10946 17711 28657]
  INT i
  BYTE append
 
  IF x=0 THEN
    s(0)=1
    s(1)='0
    RETURN
  FI
 
  i=21 append=0
  s(0)=0
  WHILE i>=0
  DO
    IF x>=fib(i) THEN
      x==-fib(i)
      s(0)==+1
      s(s(0))='1
      append=1
    ELSEIF append THEN
      s(0)==+1
      s(s(0))='0
    FI
    i==-1
  OD
RETURN
 
PROC Main()
  INT i
  CHAR ARRAY s(10)
 
  FOR i=0 TO 20
  DO
    Encode(i,s)
    PrintF("%I -> %S%E",i,s)
  OD
RETURN