Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E06mathPuzzle{
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int count =0;
- for (int i = 1; i <= 30 ; i++) {
- for (int j = 1; j <=30 ; j++) {
- for (int k = 1; k <=30; k++) {
- if (i<=30 && j<=30 && k<=30) {
- if (i < j && j < k) {
- if (i + j + k == n) {
- count++;
- System.out.printf("%d + %d + %d = %d%n", i, j, k, n);
- }
- }
- if (i > j & j > k) {
- if (i * j * k == n) {
- count++;
- System.out.printf("%d * %d * %d = %d%n", i, j, k, n);
- }
- }
- }
- }
- }
- }
- if (count==0){
- System.out.println("No!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment