Sequence: smallest number with exactly n divisors: Difference between revisions
Content added Content deleted
Line 388: | Line 388: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
===naive=== |
|||
<lang Phix>constant limit = 15 |
|||
sequence res = repeat(0,limit) |
|||
integer found = 0, n = 1 |
|||
while found<limit do |
|||
integer k = length(factors(n,1)) |
|||
if k<=limit and res[k]=0 then |
|||
res[k] = n |
|||
found += 1 |
|||
end if |
|||
n += 1 |
|||
end while |
|||
printf(1,"The first %d terms are: %v\n",{limit,res})</lang> |
|||
{{out}} |
|||
<pre> |
|||
The first 15 terms are: {1,2,4,6,16,12,64,24,36,48,1024,60,4096,192,144} |
|||
</pre> |
|||
You would need something quite a bit smarter to venture over a limit of 28. |
|||
===advanced=== |
|||
Using the various formula from the OEIS:A005179 link above.<br> |
Using the various formula from the OEIS:A005179 link above.<br> |
||
get_primes() and product() have recently been added as new builtins, if necessary see [[Extensible_prime_generator#Phix|Extensible_prime_generator]] and [[Deconvolution/2D%2B#Phix]]. |
get_primes() and product() have recently been added as new builtins, if necessary see [[Extensible_prime_generator#Phix|Extensible_prime_generator]] and [[Deconvolution/2D%2B#Phix]]. |