Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class p06 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scanner.nextLine());
  8.  
  9. for (int a = 1; a <= 9; a++) {
  10. for (int b = 9; b >= a; b--) {
  11. for (int c = 0; c <= 9; c++) {
  12. for (int d = 9; d >= c; d--) {
  13. if ((a + b + c + d) == (a * b * c * d) && n % 5 == 0) {
  14. System.out.printf("%d%d%d%d", a, b, c, d);
  15. return;
  16. }
  17.  
  18. if ((a * b * c * d) / (a + b + c + d) == 3 && n % 3 == 0) {
  19. System.out.printf("%d%d%d%d", d, c, b, a);
  20. return;
  21. }
  22. }
  23. }
  24. }
  25. }
  26. System.out.println("Nothing found");
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement