Jump to content

Sum of square and cube digits of an integer are primes: Difference between revisions

→‎{{header|jq}}: def digits:
(jq)
(→‎{{header|jq}}: def digits:)
Line 418:
end;
 
# emit an array of the decimal digits of the integer input, least significant digit first.
def digitSum: tostring | explode | map([.] | implode | tonumber) | add;
def digits:
recurse( if . >= 10 then ((. - (.%10)) / 10) else empty end) | . % 10;
 
def digitSum:
def add(s): reduce s as $_ (0; .+$_);
add(digits);
</syntaxhighlight>
'''The Task'''
2,458

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.