Spanish Miser
Answer :

There must have been 386 doubloons in one box, 8,450 in another, and 16,514 in the third, because 386 is the smallest number that can occur.
If I had asked for the smallest aggregate number of coins, the answer would have been 482, 3,362, and 6,242.
It will be found in either case that if the contents of any two of the three boxes be combined, they form a square number of coins.
It is a curious coincidence (nothing more, for it will not always happen) that in the first solution the digits of the three numbers add to 17 in every case, and in the second solution to 14.
It should be noted that the middle one of the three numbers will always be half a square.

Math Genius