private int GetLastKindAmount(Pair coinsTypes) { if (coinsTypes.Next == null) { return coinsTypes.Value; } return GetLastKindAmount(coinsTypes.Next); }
private int Calculate(int total, Pair coinsTypes) { if (total == 0) { return 1; } if (total < 0) { return 0; } if (coinsTypes == null) { return 0; } return Calculate(total - GetLastKindAmount(coinsTypes), coinsTypes) + Calculate(total, Pair.RemoveLast(coinsTypes)); }