Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class demo {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- boolean isFound = false;
- for (int a = 1; a <= 30; a++) {
- for (int b = 1; b <= 30; b++) {
- for (int c = 1; c <= 30; c++) {
- if (((a < b) && (b < c)) && (a + b + c == n)) {
- isFound = true;
- System.out.printf("%d + %d + %d = %d\n", a, b, c, n);
- } else if (((a > b) && (b > c)) && (a * b * c == n)) {
- isFound = true;
- System.out.printf("%d * %d * %d = %d\n", a, b, c, n);
- }
- }
- }
- }
- if(!isFound){
- System.out.println("No!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement