Special divisors: Difference between revisions
Content added Content deleted
(→{{header|jq}}: simplify) |
|||
Line 828: | Line 828: | ||
if . == 1 then 1 |
if . == 1 then 1 |
||
else . as $n |
else . as $n |
||
| label $out |
|||
| {i:1, i2:1, divisors: [1, $n]} |
|||
| |
| range(1; $n) as $i |
||
| ($i * $i) as $i2 |
|||
.i += 1 | .i2 = .i*.i | .divisors = null |
|||
| if $i2 > $n then break $out |
|||
else if $i2 == $n then $i |
|||
elif ($n % |
elif ($n % $i) == 0 then $i, ($n/$i) |
||
else empty |
|||
⚫ | |||
else . |
|||
end |
|||
end; |
|||
| select(.divisors).divisors[] |
|||
⚫ | |||
def is_special_divisor: |
def is_special_divisor: |
||
Line 848: | Line 847: | ||
{{out}} |
{{out}} |
||
A stream of numbers as shown elsewhere on this page. |
A stream of numbers as shown elsewhere on this page. |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<lang julia>using Primes |
<lang julia>using Primes |