0
Find the maximum of two numbers without using any if-else statements, branching, or direct comparisons.
Js
4 Réponses
+ 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
+ 1
Did you mean:
min= nb1<nb2 ? nb1: nb2;
+ 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
0
"Without if-else, branching, or direct comparisons"
Use of Math.max() count? (assumed Javascript from "Js" in Description).