Skip to content

Instantly share code, notes, and snippets.

@zaur
Created October 9, 2015 10:48
Show Gist options
  • Save zaur/6bda831b68fb2a192dc3 to your computer and use it in GitHub Desktop.
Save zaur/6bda831b68fb2a192dc3 to your computer and use it in GitHub Desktop.
public class Main {
public static void main(String[] args) {
int sum = 151;
int max3 = sum / 3;
for (int i = 0; i <= max3; i++) {
int s1 = sum - 3 * i;
int max5 = s1 / 5;
for (int j = 0; j <= max5; j++) {
int s2 = s1 - 5 * j;
if (s2 % 7 == 0) {
int num7 = s2 / 7;
System.out.println("3 - " + i + "; 5 - " + j + "; 7 - " + num7);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment