Sequence: smallest number greater than previous term with exactly n divisors: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 647: | Line 647: | ||
1 2 4 6 16 18 64 66 100 112 1024 1035 4096 4288 4624 |
1 2 4 6 16 18 64 66 100 112 1024 1035 4096 4288 4624 |
||
</pre> |
</pre> |
||
=={{header|jq}}== |
|||
'''Adapted from [[Julia]]''' |
|||
{{works with|jq}} |
|||
'''Works with gojq, the Go implementation of jq''' |
|||
<lang jq> |
|||
# The number of prime factors (as in prime factorization) |
|||
def numfactors: |
|||
. as $num |
|||
| reduce range(1; 1 + sqrt|floor) as $i (null; |
|||
if ($num % $i) == 0 |
|||
then ($num / $i) as $r |
|||
| if $i == $r then .+1 else .+2 end |
|||
else . |
|||
end ); |
|||
# Output: a stream |
|||
def A06954: |
|||
foreach range(1; infinite) as $i ({k: 0}; |
|||
.j = .k + 1 |
|||
| until( $i == (.j | numfactors); .j += 1) |
|||
| .k = .j ; |
|||
.j ) ; |
|||
"First 15 terms of OEIS sequence A069654: ", |
|||
[limit(15; A06954)]</lang> |
|||
{{out}} |
|||
<pre> |
|||
First 15 terms of OEIS sequence A069654: |
|||
[1,2,4,6,16,18,64,66,100,112,1024,1035,4096,4288,4624] |
|||
</pre> |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |