Primes whose sum of digits is 25: Difference between revisions
m
→{{header|AppleScript}}: →Idiomatic: Digit-summing code to own handler. Tidied
(Add Tcl) |
m (→{{header|AppleScript}}: →Idiomatic: Digit-summing code to own handler. Tidied) |
||
Line 347:
end repeat
repeat with
if (item
repeat with multiple from
set item multiple of o's numberList to missing value
end repeat
Line 357:
return o's numberList's numbers
end sieveOfEratosthenes
on sumOfDigits(n) -- n assumed to be a positive decimal integer.
set n to n div 10
return sum
end sumOfDigits
on numbersWhoseDigitsSumTo(numList, targetSum)
Line 364 ⟶ 375:
end script
repeat with
▲ set digitSum to n mod 10
▲ repeat until n is 0
▲ set n to n div 10
▲ set digitSum to digitSum + n mod 10
▲ end repeat
end repeat
Line 378 ⟶ 383:
-- Task code:
{{output}}
|