Matlab Code Coconuts, Sailors, and a Monkey

Ashish Khare posted the following problem on Linkedin:

I created some Matlab code which not only solved this problem, but can solve a generic version of the problem. It allows the user to easily change the number of sailors and how many coconuts the monkey receives.

15621 coconuts!  If we increase the problem to 6 sailors (who are more generous and give the monkey two coconuts)

It takes a massive jump, making 15621 coconuts seem like a small number of coconuts.