Here you can find the source of primeFactorization()
Number.prototype.primeFactorization = function() { var ans = [];/* ww w. j av a 2 s.co m*/ var primes = []; var temp = this; for (let i = 0; i <= temp/2; i++) { if (i.allDivisors().length == 2) { primes.push(i) } } for (let i = 0; i < primes.length; i++) { while (temp.isDivisor(primes[i])) { ans.push(primes[i]); temp = temp / primes[i]; } } console.log(ans); }
Number.prototype.isPrime = function() { var primeCandidate = this; if(primeCandidate <= 1 || primeCandidate%1 !== 0) return false var i = 2; var top = Math.floor(Math.sqrt(primeCandidate)); while(i<=top){ if(primeCandidate%i === 0){ return false; } i++; return true;
Number.prototype.isPrime=function(){ for(var n=2;n<this;) if(!(this%n++)) return !1; return !0} function PrimeTime(num) { return num.isPrime(); PrimeTime(readline()); ...
Number.prototype.isPrime=function(){ for(var n=2;n<this;) if(!(this%n++)) return !1; return !0 var getNextPrime = function(number, max) { while(++number <= max) if (number.isPrime()) ...
Number.prototype.isPrime = function () { var i = 2; while (i<=this - 1) { if (this % i ==0) { return false; break; i++; if (i == this) { return true; };
Number.prototype.primeFactorization = function(){ var ans = []; var primes = []; var temp = this; for(let i=2; i<=this/2; i++){ if(i.divisors().length==2){ primes.push(i) for(let i = 0; i<primes.length;i++){ while(temp.isDivisor(primes[i])){ ans.push(primes[i]); temp = temp/primes[i]; return ans;
Number.prototype.primeFactorization = function(){ var ans = []; var temp = this; var primes = []; for(let i = 2;i<=this/2;i++){ if(i.divisors().length == 2){ primes.push(i); if(temp==1){ break; ...
Number.prototype.primeFactorization = function () { var ans = []; var primes = []; var temp = this; for (let i = 2; i <= temp / 2; i++) { if (i.divisors().length == 2) { primes.push(i); for (let i = 0; i < primes.length; i++) { while (i.isDivisor(temp)) { ans.push(primes[i]); temp = temp / primes[i]; return ans;
Number.prototype.primeFactorization = function () { var ans = []; var primes = []; var temp = this; for (let i = 2; i <= temp / 2; i++) { if (i.divisors().length == 2) { primes.push(i); for (let i = 0; i < primes.length; i++) { while (temp.isDevisor(primes[i])) { ans.push(primes[i]); temp = temp / primes[i]; return ans;
Number.prototype.primeFactorization = function (){ console.log("prime aangekomen"); var ans = []; var primes = []; var temp = this; for(let i = 2; i<temp/2; i++){ if(i.divisors().length == 2){ primes.push(i); for (let i =0; i<primes.length; i++){ while(temp.isDivisor(primes[i])){ ans.push(primes[i]); temp = temp/primes[i]; return ans; };