Skip to content

Instantly share code, notes, and snippets.

@bitcpf
Created September 22, 2014 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitcpf/9ac3344682a848d8bf05 to your computer and use it in GitHub Desktop.
Save bitcpf/9ac3344682a848d8bf05 to your computer and use it in GitHub Desktop.
public class Q9_8 {
public static int Permcoin(int n, int coin){
int next_coin = 0;
switch (coin){
case 25:
next_coin = 10;
break;
case 10:
next_coin = 5;
break;
case 5:
next_coin = 1;
break;
case 1:
return 1;
}
int ways = 0;
for(int i =0; i*coin <= n;i++){
ways += Permcoin(n - i*coin,next_coin);
}
return ways;
}
public static void main(String[] args){
int testn = 100;
System.out.println(testn);
System.out.println(Permcoin(testn,25));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment