Sequence: smallest number with exactly n divisors: Difference between revisions
Content deleted Content added
→{{header|zkl}}: added code |
m →{{header|zkl}}: tweak |
||
Line 325: | Line 325: | ||
<lang zkl>fcn countDivisors(n) |
<lang zkl>fcn countDivisors(n) |
||
{ [1.. n.toFloat().sqrt()].reduce('wrap(s,i){ s + (if(0==n%i) 1 + (i!=n/i)) },0) } |
{ [1.. n.toFloat().sqrt()].reduce('wrap(s,i){ s + (if(0==n%i) 1 + (i!=n/i)) },0) } |
||
A005179w:=(1).walker(*).tweak(fcn(n){ |
|||
⚫ | |||
(1).walker(*).tweak(fcn(n){ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
if(n == (d:=countDivisors(N+=1))) return(N); |
|||
⚫ | |||
if(n<d and not cache.find(d)) cache[d]=N; |
|||
⚫ | |||
if(n<d and not cache.find(d)) cache[d]=N; |
|||
⚫ | |||
} |
|||
⚫ | |||
⚫ | |||
<lang zkl>N:=15; |
<lang zkl>N:=15; |
||
println("First %d terms of OEIS:A005179 |
println("First %d terms of OEIS:A005179".fmt(N)); |
||
A005179w |
A005179w.walk(N).concat(" ").println();</lang> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
First 15 terms of OEIS:A005179 |
First 15 terms of OEIS:A005179 |
||
1 2 4 6 16 12 64 24 36 48 1024 60 4096 192 144 |
1 2 4 6 16 12 64 24 36 48 1024 60 4096 192 144 |
||
</pre> |
</pre> |