Funny.m and the function as_per_question takes a very traditional way of solving the question, uses combinatorial arguments(using beggars method) to solve the same , but this procedure has issues when we deal with huge values of n as the time complexity increases to exbortionrily high and moreover the computer gives you erronous results for the same, but on doing so I realised that the answers that we get are following a fibonacci sequence so one more fast algorithm that can be carried out is doing a golden ratio approximation, so that is done in the second attempt type better to start the program and now enter values as described by the question but it is to be noted that this is an appoximate method to the question , it is fast but is not exactly equal to the actual answer. One can make it more exact by keeping higher values of the fibonacci sequence as the base which in this I set it to 377/233 and running the as_per_question code for values less than the set values
Moreover suppose you have entered the value 2 13 131 output: 1.0e+11 *
0.0000
1.6424
than u will get weired answer as matlab tries to give it exponentiared to certain values, in order to understand the value inspect result. it is there where u will understand the same better.
Suggestions : Use funny.m as long as warnings does not pop up after that use better.m(golden ratio test based) but the golden ration test based algorithm is an approximation to the original algorithm and the approximation can be bettered by taking higher values of the fibonacci sequence for approximation , it is to be noted that a meagre difference in decimal point when exponentiated leads to huge differences and this can be seen in this case.