Largest proper divisor of n: Difference between revisions
→{{header|AppleScript}}: Corrected to make the result for 1 a task requirement rather than 1's largest proper divisor.
(→{{header|AppleScript}}: Corrected to make the result for 1 a task requirement rather than 1's largest proper divisor.) |
|||
Line 75:
<lang applescript>on largestProperDivisor(n)
if (n mod 2 = 0) then return n div 2
if (n mod 3 = 0) then return n div
repeat with i from
▲ if (n mod i = 0) then return n div i
▲ end repeat
▲ return 1
end largestProperDivisor
on task(
script o
property LPDs : {}
Line 95 ⟶ 92:
set w to (count (max as text)) * 2 + 3
set padding to text 1 thru (w -
set end of o's LPDs to "1:1" & padding
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ""
set c to
repeat with n from
set end of o's LPDs to text 1 thru w of ((n as text) & ":" & largestProperDivisor(n) & padding)
set c to c + 1
Line 115 ⟶ 113:
end task
task(
{{output}}
|