Sequence: smallest number greater than previous term with exactly n divisors: Difference between revisions
Content added Content deleted
(Created page with "The Anti-primes Plus sequence are the natural numbers in which is nth item has n factors.") |
No edit summary |
||
Line 1: | Line 1: | ||
The Anti-primes Plus sequence are the natural numbers in which is nth item has n factors. |
The Anti-primes Plus sequence are the natural numbers in which is nth item has n factors. |
||
=={{header|Ring}}== |
|||
<lang ring> |
|||
# 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> |
|||
{{out}} |
|||
<pre> |
|||
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... |
|||
</pre> |
Revision as of 04:29, 9 April 2019
The Anti-primes Plus sequence are the natural numbers in which is nth item has n factors.
Ring
<lang ring>
- 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...