JSFiddle - React, Tailwind, and code Playground
JavaScript
N=1000; //we're finding the Nth practical number
k=1; //this is the number we return
N--; //because of the way the while loop is set up
while(N)
if(
(function(x){ //return true if practical, false otherwise
p=[]; //prime factors
e=[]; //exponents
c=0; //number of prime factors
if(x%2|x==1)
return; //odd numbers greater than 1 can never be practical
while(x>1){ //factorise
f=x; //smallest factor
for(j=2;j<=Math.sqrt(f);j++) //find f
if(f%j==0){
f=j;
break;
}
if(!k|f!=p[c-1]){ //new prime factor
p.push(f);
e.push(2);
c++
}else e[c-1]++; //increase exponent of existing PF
x/=f
}
for(i=1;i<c;i++) { //test sigma(x) for all i<c (see wikipedia)
j=i;
P=1;
while(j--)
P*=(Math.pow(p[j],e[j])-1)/(p[j]-1); //build the product
if(p[i]>=P+2)
return; //fails sigma-test
}
return 1 //passes
})(k++) //increment k
)
N--; //decrement N (this way round to make while loop fewer chars)
k--; //we end up with k 1 too high because we increment k after the loop not before
document.body.innerHTML+=k