Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exam28_29April;
- import java.util.Scanner;
- public class SumAndProduct {
- public static void main(String[] agrs) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- boolean isFound = true;
- Here:
- for (int a = 1; a <= 9; a++) {
- for (int b = 9; b >= a; b--) {
- for (int c = 0; c <= 9; c++) {
- for (int d = 9; d >= c; d--) {
- if (a + b + c + d == a * b * c * d && n % 10 == 5) {
- System.out.println(a + "" + b + "" + c + "" + d);
- isFound = false;
- break Here;
- } else if ((a * b * c * d) / (a + b + c + d) == 3 && n % 3 == 0) {
- System.out.println(d + "" + c + "" + b + "" + a);
- isFound = false;
- break Here;
- }
- }
- }
- }
- }
- if (isFound) {
- System.out.println("Nothing found");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement