O'Halloran numbers: Difference between revisions

Added AppleScript.
No edit summary
(Added AppleScript.)
Line 59:
8 12 20 36 44 60 84 116 140 156 204 260 380 420 660 924
</pre>
 
=={{header|AppleScript}}==
<syntaxhighlight lang="applescript">on OHalloranNumbers(max)
script o
property evens : {missing value, missing value}
end script
repeat with n from 6 to max by 2
set end of o's evens to n
end repeat
set halfMax to max div 2
set halfMaxMinus2 to halfMax - 2
repeat with x from 1 to halfMaxMinus2
repeat with y from 1 to (halfMaxMinus2 div x)
repeat with halfArea from (x * y + x + y) to halfMax by (x + y)
set o's evens's item halfArea to missing value
end repeat
end repeat
end repeat
return o's evens's integers
end OHalloranNumbers
 
return OHalloranNumbers(1000 - 1)
 
(* Repeat logic condensed from:
repeat with x from 1 to halfMaxMinus2
repeat with y from 1 to x
set xy to x * y
if (xy > halfMaxMinus2) then exit repeat
repeat with z from 1 to y
set halfArea to xy + (x + y) * z
if (halfArea > halfMax) then exit repeat
set o's evens's item halfArea to missing value
end repeat
end repeat
end repeat
*)</syntaxhighlight>
 
{{output}}
<syntaxhighlight lang="applescript">{8, 12, 20, 36, 44, 60, 84, 116, 140, 156, 204, 260, 380, 420, 660, 924}</syntaxhighlight>
 
=={{header|Arturo}}==
557

edits