Question: You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the **largest possible** positive Fibonacci number. E.g.:

```
1 = 1
2 = 2
3 = 3
4 = 3 + 1
12 = 8 + 3 + 1
13 = 13
100 = 89 + 8 + 3

```

Now, I call a *Fibonacci product* the same lists as above, but with the addition replaced by multiplication. For example, \$f(100) = 89 \times 8 \times 3 = 2136\$.

Write a program or function that given a positive integer *n* returns the Fibonacci product of that number.

---

Testcases:

```
1: 1
2: 2
3: 3
4: 3
5: 5
6: 5
7: 10
8: 8
9: 8
42: 272
1000: 12831
12345: 138481852236

```

Answer: 
[Jelly](http://github.com/DennisMitchell/jelly), ~~16~~ 15 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
==========================================================================================================================

```
Rf1+Ð¡¤ṪạµÐĿIAP

```

Not particularly fast or memory friendly, but efficient enough for all test cases. [Try it online!](http://jelly.tryitonline.net/#code=UmYxK8OQwqHCpOG5quG6ocK1w5DEv0lBUA&input=&args=MTIzNDU)

### How it works

```
Rf1+Ð¡¤ṪạµÐĿIAP  Main link. Argument: n (integer)

         µ       Combine the chain to the left into a link.
          ÐĿ     Apply that link until the results are no longer unique.
                 Return the list of unique results.
      ¤            Combine the two links to the left into a niladic chain.
  1                  Set the left (and right) argument to 1.
   +D¡               Apply + to the left and right argument, updating the left
                     argument with the sum, and the right argument with the
                     previous value of the left one. Return the list of results.
                     Repeat this process n times.
                   This yields n + 1 Fibonacci numbers, starting with 1, 2.
R                  Range; map k to [1, ..., k].
 f                 Filter; keep the items in the range that are Fibonacci numbers.
       Ṫ           Tail; yield the last one or 0 if the list is empty.
        ạ          Absolute difference with k.
                   This is the argument of the next iteration.
            I    Compute the increments of the arguments to the loop, yielding
                 the selected Fibonacci numbers (with changed sign).
             A   Apply absolute value to each.
              P  Compute their product.  

```
JavaScript (ES6), ~~78~~ 42 bytes
---------------------------------

```
f=(n,a=1,b=1)=>n?b>n?a*f(n-a):f(n,b,a+b):1

```

Port of @Sp3000's answer. Original 78 byte version:

```
f=(n,a=[2,1])=>n>a[0]?f(n,[a[0]+a[1],...a]):a.map(e=>e>n?0:(r*=e,n-=e),r=1)&&r

```