Sequence: smallest number greater than previous term with exactly n divisors

From Rosetta Code
Revision as of 04:53, 9 April 2019 by CalmoSoft (talk | contribs)
Task
Sequence: smallest number greater than previous term with exactly n divisors
You are encouraged to solve this task according to the task description, using any language you may know.

The Anti-primes Plus sequence are the natural numbers in which each nth item has n factors.

Ring

<lang ring>

  1. Project : ANti-primes

see "working..." + nl see "wait for done..." + nl + nl see "the first 15 Anti-primes Plus are:" + nl + nl num = 1 n = 0 result = list(15) while num < 16

     n = n + 1
     div = factors(n)
     if div = num
        result[num] = n
        num = num + 1
     ok

end see "[" for n = 1 to len(result)

   if n < len(result)
      see string(result[n]) + ","
   else
      see string(result[n]) + "]" + nl + nl
   ok

next see "done..." + nl

func factors(an)

    ansum = 2
    if an < 2
       return(1)
    ok
    for nr = 2 to an/2
        if an%nr = 0
           ansum = ansum+1
        ok
    next
    return ansum

</lang>

Output:
working...
wait for done...

the first 15 Anti-primes Plus are:

[1,2,4,6,16,18,64,66,100,112,1024,1035,4096,4288,4624]

done...