Calculate the sequence where each term an is the nth that has n divisors.

Task
Show here, on this page, at least the first 15 terms of the sequence.

See also
OEIS:A073916
Related tasks
Sequence: smallest number greater than previous term with exactly n divisors
Sequence: smallest number with exactly n divisors
var [const] BI=Import("zklBigNum"), pmax=25;  // libGMP
p:=BI(1);
primes:=pmax.pump(List(0), p.nextPrime, "copy");  //-->(0,3,5,7,11,13,17,19,...)
 
fcn countDivisors(n){
   count:=1;
   while(n%2==0){ n/=2; count+=1; }
   foreach d in ([3..*,2]){
      q,r := n/d, n%d;
      if(r==0){
	 dc:=0;
	 while(r==0){
	    dc+=count;
	    n,q,r = q, n/d, n%d;
	 }
	 count+=dc;
      }
      if(d*d > n) break;
   }
   if(n!=1) count*=2;
   count
}
 
println("The first ", pmax, " terms in the sequence are:");
foreach i in ([1..pmax]){
   if(BI(i).probablyPrime()) println("%2d : %,d".fmt(i,primes[i].pow(i-1)));
   else{
      count:=0;
      foreach j in ([1..*]){
         if(i%2==1 and j != j.toFloat().sqrt().toInt().pow(2)) continue;
	 if(countDivisors(j) == i){
	    count+=1;
	    if(count==i){
	       println("%2d : %,d".fmt(i,j));
	       break;
	    }
	 }
      }
   }
}