4 ms·
Somebody help me with #21 What're those round numbers?
by zaph0d 17y ago
Somebody help me with #21
What're those round numbers?
- sharkbrainguy 17y agovar round = function(number){ var binary = number.toString(2); var hex = number.toString(16); var R = function(str){ return /^10*$/.test(str); }; return R(binary) && R(hex); }; That I wrote this just shows how special class I am... If a number is "round" in base-n that just means it's a power of n, and obviously all powers of 16 are also powers of 2.