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‎‎


func countDivisors(n) {
    var count = 0
    var i = 1
    while i * i <= n {
        if n % i == 0 {
            if i == n / i {
                count += 1
            } else {
                count += 2
            }
        }
        i += 1
    }
    return count
}
 
let max = 15
print("The first \(max) terms of the sequence are:")
var (i, next) = (1, 1)
while next <= max {
    if next == countDivisors(i) {
        print("\(i) ", terminator: "")
        next += 1
    }
    i += 1
}
 
print()