One number is greater than another by 4, their sum is 32. What are the two numbers? Write a function which could solve this for any two numbers (x and y) with any difference between them.​

X+y=32

X-y=4
Add the two equation
2x=36
X=18
Put it back in any of the two equations
Y=14
DIRECT METHOD
X=(32+4)/2=18
Y=(32-4)/2=14

To solve this problem, we can approach it using algebraic equations.

Let's assume that the greater number is x and the other number is y. Given that one number is greater than the other by 4, we can write the equation:

x = y + 4

We are also given that the sum of the two numbers is 32, so we can write another equation:

x + y = 32

Now, we have a system of two equations with two variables. We can solve this system of equations using various methods, such as substitution or elimination, to find the values of x and y.

Here's an example of how we can write a function to solve this problem for any two numbers x and y with any difference between them:

```
function findNumbersWithDifference(x, y) {
let result = {};

// Equations based on the problem statement
result.x = (x + y + Math.abs(x - y)) / 2;
result.y = (x + y - Math.abs(x - y)) / 2;

return result;
}
```

This function takes two parameters, x and y, representing the greater number and the other number, respectively. It calculates the values of x and y based on the equations derived from the problem statement. Finally, it returns an object with the values of x and y.

So, to solve the specific problem you mentioned (one number is greater than another by 4 and their sum is 32), you can use this function as follows:

```
let result = findNumbersWithDifference(4, 28);
console.log(result.x); // Output: 16
console.log(result.y); // Output: 12
```

In this example, the greater number (x) is 28, and the other number (y) is 4. The function will calculate and return the values of x and y as 16 and 12, respectively.