Weird numbers: Difference between revisions

m
→‎{{header|AppleScript}}: →‎Idiomatic: Subset-sum matching handler relabelled, reparametered, and made partly iterative.
m (→‎{{header|AppleScript}}: →‎Idiomatic: Subset-sum matching handler relabelled, reparametered, and made partly iterative.)
Line 295:
end properDivisors
 
on containsSubtotalcanSumTo(lst, subtotal, i, jtarget)
script o
property l : lst
on cscst(subtotaltarget, ji)
set n to item j of my lrepeat
if ( set n =to item subtotal)i thenof returnmy truel
if (jn = itarget) then return falsetrue
set j to j -if (i = 1) then return false
set i to i - 1
return if (((subtotaln >< ntarget) and (cscst(subtotaltarget - n, ji))) orthen (cs(subtotal,return j)))true
end repeat
end cs
end script
return o's cscst(subtotaltarget, jcount o's l)
end canSumTo
end containsSubtotal
 
on isWeird(n)
Line 322 ⟶ 323:
end repeat
return ((sum > n) and (not containsSubtotalcanSumTo(o's divisors, sum - n, 1, (count o's divisors))))
end isWeird
 
557

edits