Sequence: smallest number greater than previous term with exactly n divisors: Difference between revisions
Content deleted Content added
ReeceGoding (talk | contribs) Added R. |
|||
Line 974: | Line 974: | ||
4624 |
4624 |
||
</lang> |
</lang> |
||
=={{header|R}}== |
|||
<lang R>#Need to add 1 to account for skipping n. Not the most efficient way to count divisors, but quite clear. |
|||
divisorCount <- function(n) length(Filter(function(x) n %% x == 0, seq_len(n %/% 2))) + 1 |
|||
A06954 <- function(terms) |
|||
{ |
|||
out <- 1 |
|||
while((resultCount <- length(out)) != terms) |
|||
{ |
|||
n <- resultCount + 1 |
|||
out[n] <- out[resultCount] |
|||
while(divisorCount(out[n]) != n) out[n] <- out[n] + 1 |
|||
} |
|||
out |
|||
} |
|||
print(A06954(15))</lang> |
|||
{{out}} |
|||
<pre>[1] 1 2 4 6 16 18 64 66 100 112 1024 1035 4096 4288 4624</pre> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |