user
Calculate the sequence where each term **an** is the **smallest natural number** greater than the previous term, that has exactly **n** divisors.

Task

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

See also
:   * OEIS:A069654

Related tasks
:   * Sequence: smallest number with exactly n divisors
    * Sequence: nth number with exactly n divisors‎‎
assistant
(formerly Perl 6)

**Works with**: Rakudo version 2019.03

```
sub div-count (\x) {
    return 2 if x.is-prime;
    +flat (1 .. x.sqrt.floor).map: -> \d {
        unless x % d { my \y = x div d; y == d ?? y !! (y, d) }
    }
}

my $limit = 15;

my $m = 1;
put "First $limit terms of OEIS:A069654";
put (1..$limit).map: -> $n { my $ = $m = first { $n == .&div-count }, $m..Inf };

```

Output:

```
First 15 terms of OEIS:A069654
1 2 4 6 16 18 64 66 100 112 1024 1035 4096 4288 4624

```