Implemented historical commands

This commit is contained in:
Borys Levytskyi
2015-04-03 19:31:57 +03:00
parent 8e5be22fe3
commit 022c65635c
12 changed files with 148 additions and 122 deletions

View File

@@ -1,23 +1,21 @@
(function(app, should){
var calc = {};
app.component('calc', {
calc.numberOfBits = function(num) {
should.bePositiveInteger(num);
return Math.floor(Math.log(num) / Math.log(2)) + 1;
};
numberOfBits: function (num) {
should.bePositiveInteger(num);
return Math.floor(Math.log(num) / Math.log(2)) + 1;
},
calc.maxNumberOfBits = function (arr) {
maxNumberOfBits: function (arr) {
var counts = [], num;
for(var i=0;i<arr.length; i++)
{
num = arr[i];
counts.push(this.numberOfBits(num));
var counts = [], num;
for (var i = 0; i < arr.length; i++) {
num = arr[i];
counts.push(this.numberOfBits(num));
}
return Math.max.apply(null, counts);
}
return Math.max.apply(null, counts);
};
app.service('calc', calc);
});
})(window.app, window.should);