Skip to content

Instantly share code, notes, and snippets.

@zeroDivisible
Created January 20, 2013 22:05
Show Gist options
  • Save zeroDivisible/4582113 to your computer and use it in GitHub Desktop.
Save zeroDivisible/4582113 to your computer and use it in GitHub Desktop.
This is simple solution to Problem #31 on Project Euler.
public class problem31 {
final static int TOTAL = 200;
public static void main(String[] args) {
int[] coins = {1, 2, 5, 10, 20, 50, 100, 200};
int[] ways = new int[TOTAL + 1];
ways[0] = 1;
for(int coin: coins)
for(int j = coin; j <= TOTAL; j++)
ways[j] += ways[j - coin];
System.out.println("Result: " + ways[TOTAL]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment