Javascript Number divisors()
Number.prototype.divisors = function () { "use strict"; var ans = [], max = this;/*from w ww . j a v a2 s.c o m*/ for (i = 1; i < max; i += 1) { if (max.isDivisor(i)) { ans.push(i); } } if (ans.length > 30) { console.log("amount " + ans.length); } return ans; };
Number.prototype.divisors = function() { var ans = []; if (this.isInteger()) { for (let i = 1; i < Math.abs(this / 2+1 ); i++) { if ((this).isDivisor(i)) { ans.push(i);/*from w ww . j a v a 2s . com*/ } } ans.push(this); } return ans; }
Number.prototype.divisors = function(){ var ans = [];/*from www. ja v a 2s .c o m*/ var max = this; for(i=1;i<=max/2;i++){ if(max.isDivisor(i)){ ans.push(i); } } ans.push(max.valueOf()); return ans; }
Number.prototype.divisors = function(){ var ans = []; var max = this; for(i = 1; i<=max/2; i++){ if(this.isDivisor(i)){ ans.push(i);//from w w w . j a v a 2 s. com } } ans.push(this.valueOf()); return ans; }
Number.prototype.divisors = function(){ var ans = [];// w w w .j a v a 2 s. c o m var max= this; for(var i=1; i<=this; i++){ if(this.isDivisor(i)){ ans.push(i); } } return ans; }
Number.prototype.divisors = function () { var ans = [];/*www . j av a2s . co m*/ var max = this; for (i=1; i < max/2; i++) { if(max.isDivisor(i)){ ans.push(i); } } ans.push(max.valueOf()); return ans; };