Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package IZPIT;
- import java.util.Scanner;
- public class Sum_And_Product {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- boolean nova = false;
- 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--) {
- int sum = a + b + c + d;
- int product = a * b * c * d;
- if (sum == product && n % 10 == 5) {
- System.out.printf("%d%d%d%d%n", a, b, c, d);
- nova = true;
- break;
- } else if (product / sum == 3 && n % 3 == 0) {
- System.out.printf("%d%d%d%d%n", d, c, b, a);
- nova = true;
- break;
- }
- }
- if(nova){
- break;
- }
- }
- if(nova){
- break;
- }
- }
- if(nova){
- break;
- }
- }
- if(nova){
- System.out.print("");
- }else {
- System.out.println("Nothing found");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement