Sum multiples of 3 and 5: Difference between revisions
→{{header|AppleScript}}
Line 20:
{{Trans|JavaScript}}
<lang AppleScript>
-- sums of all multiples of 3 or 5 below or equal to N▼
-- for N = 10 to N = 10E8 (limit of AS integers)▼
foldl(sum35Result, "", map(tenE, range(1, 8)))▼
end run▼
on sum35(n)
sumMults(n, 3) + sumMults(n, 5) - sumMults(n, 15)
Line 44 ⟶ 37:
-- TESTING
on run
▲ -- sums of all multiples of 3 or 5 below or equal to N
▲ -- for N = 10 to N = 10E8 (limit of AS integers)
▲ foldl(sum35Result, "", map(tenE, range(1, 8)))
▲end run
-- tenE :: Int -> Int
Line 55:
"</sup> -> " & sum35(x) & "<br>"
end sum35Result
-- GENERIC FUNCTIONS
|