Numbers whose count of divisors is prime: Difference between revisions

m
→‎{{header|AppleScript}}: Variable label changed. Source of squares-only idea acknowledged.
m (→‎{{header|AppleScript}}: Changed a couple of variable labels.)
m (→‎{{header|AppleScript}}: Variable label changed. Source of squares-only idea acknowledged.)
Line 163:
 
=={{header|AppleScript}}==
Only squares checked, as per the Discussion page.
<syntaxhighlight lang="applescript">on countFactors(n) -- Positive ns only.
if (n < 4) then return 2 - ((n = 1) as integer)
Line 189 ⟶ 190:
on task()
set limit to 100000 - 1
set maxLennWidth to (count (limit as text))
set inset to " "'s text 1 thru (maxLennWidth - 1)
set output to {"Positive integers < " & (limit + 1) & " whose divisor count is an odd prime:"}
set row to {}
Line 198 ⟶ 199:
if (countFactors(countFactors(n)) = 2) then
set counter to counter + 1
set row's end to (inset & n)'s text -maxLennWidth thru -1
if ((count row) = 10) then
set output's end to join(row, " ")
557

edits