Jump to content

Numbers which are the cube roots of the product of their proper divisors: Difference between revisions

→‎{{header|jq}}: def harness:
(→‎{{header|jq}}: def numbers_being_cube_roots_of_their_proper_divisors:)
(→‎{{header|jq}}: def harness:)
Line 481:
'''Generic utilities'''
<syntaxhighlight lang=jq>
# Notice that `prod(empty)` evaluates to 1.
def prod(s): reduce s as $x (1; . * $x);
 
Line 504 ⟶ 505:
 
# print first 50 and then the 500th, 5000th, and $limit-th
def taskharness(generator; $limit):
( label $out
"First 50 numbers which are the cube roots of the products of their proper divisors:",
| foreach generator as $n (
( label $out
{ numbers50: [],
| foreach numbers_being_cube_roots_of_their_proper_divisors as $n (
{ numbers50count: [],0 };
.emit = count: 0};null
| .emitcount += null1
| |if .count +=> 1$limit
|then if .count >break $limitout
else if .count <= 50
then break $out
else if then .countnumbers50 <+= 50[$n]
thenelse .numbers50 += [$n]
else .end
| if .count == 50 end
| ifthen .countemit == 50 .numbers50
elif .count then| .emitIN(500, =5000, .numbers50$limit)
then .emit elif= "\(.count)th: | IN\(500, 5000, $limitn)"
thenelse .emit = "\(.count)th: \($n)"
else .end
end end)
| .emit // empty end );
 
| .emit // empty ) ;
"First 50 numbers which are the cube roots of the products of their proper divisors:",
| foreach harness(numbers_being_cube_roots_of_their_proper_divisors; as $n (50000)
task(50000)
</syntaxhighlight>
 
</syntaxhighlight>
{{out}}
2,502

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.