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

m
→‎{{header|AppleScript}}: Tidied and added observation about the numbers' fourth powers.
(Added AppleScript.)
m (→‎{{header|AppleScript}}: Tidied and added observation about the numbers' fourth powers.)
Line 105:
 
=={{header|AppleScript}}==
ThisLike tooother doessolutions thehere, this checks for numbers having "seven proper divisors" test rather than doing the multiplications, which saves time and avoids products that are too large for AppleScript numbers.
<syntaxhighlight lang="applescript">on properDivisors(n)
set output to {}
Line 137:
 
on task()
set output to {"First 50 numbers whose cubes are the products of their proper divisors:"}, ¬
"(and of course whose fourth powers are the products of ALL their positive divisors):"}
set pad to " end if"
set n to 1
set foundfirst50 to {" 1"}
repeat 49 times
set subgroup to {text -5 thru -1 of (" " & n)}
repeat
set n to n + 1
ifrepeat until ((count properDivisors(n)) = 7) then
set foundn to foundn + 1
end if (found > 5000) thenrepeat
set end of first50 to text -5 thru if-1 of (foundpad =& 50000n) then
end ifrepeat
set end of output to "50,000th: " & text -6 thru -1 of (" " & n)
repeat with i from 1 to 41 by exit repeat10
set end of output to join(first50's items i endthru (i + 9), if"")
end repeat
else if (found > 500) then
set |count| to 50
if (found = 5000) then set end of output to " 5,000th: " & text -6 thru -1 of (" " & n)
repeat with target in {500, 5000, 50000}
else if (found > 50) then
repeat with |count| from (|count| + 1) to target
if (found = 500) then set end of output to " 500th: " & text -6 thru -1 of (" " & n)
elseset n to n + 1
repeat until ((count set end of subgroup to text -5 thru -1 of properDivisors("n)) = " & n7)
ifset (foundn modto 10n =+ 0) then1
set end of output to join(subgroup, "")repeat
end set subgroup to {}repeat
set end of output to text -6 thru -1 of (pad & set|count|) end of output to& "50,000thth: " & text -6 thru -1 of (" "pad & n)
end if
end if
end if
end repeat
Line 170 ⟶ 169:
 
{{output}}
<syntaxhighlight lang="applescript">"First 50 numbers whose cubes are the products of their proper divisors:
(and of course whose fourth powers are the products of ALL their positive divisors):
1 24 30 40 42 54 56 66 70 78
88 102 104 105 110 114 128 130 135 136
Line 177:
255 258 266 273 282 285 286 290 296 297
500th: 2526
5,000th 5000th: 23118
50,000th 50000th: 223735"</syntaxhighlight>
 
=={{header|BASIC}}==
557

edits