Write a method that finds the maximum of two numbers. You should not use if-else or any other comparison operator.
Answers
Answered by
0
let the two no. is a,b.
To get the maximum max(a,b) you step on the midpoint (a+b)/2 and then "walk" half the distance between them on the positive direction on real line, that is, you add |a−b|/2 so you get
max(a,b)=(a+b+|a−b|)/2
Similar questions