Assignemnt #119, Number Puzzles IV

Code

    public class NumberPuzzle4 {
    
        public static void main(String[] args) {
        
            int n, y, z;
            
            for (int x = 1; x <= 25; x++) {
            
                for (n = 1; n <= 25; n++) {
                
                    for (y = 1; y <= 25; y++) {
                    
                        for (z = 1; z <= 25; z++) {
                        
                            if (((x + n + y + z) == 45) && (x + 2 == n - 2) && (x + 2 == y * 2) && (x + 2 == z / 2))
                                System.out.println(x + " " + n + " " + y + " " + z);
                        }
                        z -= 24;
                    }
                    y -= 24;
                }
                n -= 24;
            }
        }
    }


    

Picture of the output

Assignment 119