Finding maximal and minimal values under certain limitations

16 Views Asked by At

given a function that gets 3 numbers and outputs the maximal of them, I have to find using only this function the minimal number out of 3 given numbers.

max(x1,x2,x3) returns maximal value

for now, I think I should get the sum of all the 3 numbers, and subtract then the max(x1,x2,x3) but yet I have to subtract the smaller maximal out of the remained.

would appreciate your help,

1

There are 1 best solutions below

0
On

ok, found out by myself. I should multiply x1, x2, x3, - everyone of them by -1.

In this way, the maximal number turns into the minimal and vice versa.