0

Find the maximum of two numbers without using any if-else statements, branching, or direct comparisons.

Js

16th Nov 2020, 11:42 AM
Stephen Otieno
4 Answers
+ 2
You mean like this? It is c and maximum of a list, not of two numbers, but the idea can work in your case too https://code.sololearn.com/cP1LtPA7WdBz/?ref=app
16th Nov 2020, 7:45 PM
Volodymyr Chelnokov
Volodymyr Chelnokov - avatar
+ 1
Did you mean: min= nb1<nb2 ? nb1: nb2;
16th Nov 2020, 1:10 PM
CHERIEF Houcine Abdelkader
CHERIEF Houcine Abdelkader - avatar
+ 1
Here is a javascript attempt using a bit different approach. I am not very good at javascript, so if you find a problem (apart from giving variables outside of int range), please tell. https://code.sololearn.com/WZr2PZJqQI0M/?ref=app
16th Nov 2020, 9:47 PM
Volodymyr Chelnokov
Volodymyr Chelnokov - avatar
0
"Without if-else, branching, or direct comparisons" Use of Math.max() count? (assumed Javascript from "Js" in Description).
16th Nov 2020, 1:10 PM
Ipang