int[] options = {1, 2, 5, 10, 20, 50, 100, 200};
int expectedSum = 200;
@Override
public void run() {
result = solveRecursive(0, 0);
}
private int solveRecursive(final int currentSum, int currentIterations) {
int localCurrentIterations = currentIterations;
for (int option : options) {
if (currentSum + option <= expectedSum) {
localCurrentIterations += solveRecursive(currentSum + option, currentIterations);
}
}
return localCurrentIterations;
}