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

Content added Content deleted
(jq)
(→‎{{header|jq}}: def digits:)
Line 418: Line 418:
end;
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>
</syntaxhighlight>
'''The Task'''
'''The Task'''