Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Third solution in Clear category for [old] Binary Count by vincent.tscherter
"use strict";
function binaryCount(n) {
return n.toString(2).split('1').length-1
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(binaryCount(4), 1);
assert.equal(binaryCount(15), 4);
assert.equal(binaryCount(1), 1);
assert.equal(binaryCount(1022), 9);
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
Nov. 16, 2016
Comments: