Sum digits of an integer: Difference between revisions
Content deleted Content added
add →Joy |
|||
Line 2,331: | Line 2,331: | ||
f0e -> 29 |
f0e -> 29 |
||
999ABCXYZ -> 162</pre> |
999ABCXYZ -> 162</pre> |
||
=={{header|Joy}}== |
|||
<syntaxhighlight lang="joy">DEFINE digitsum == |
|||
[swap string] [dup [strtol] dip] [] ifte |
|||
[<] [pop] [dup rollup div rotate] [+] linrec. |
|||
1 10 digitsum. |
|||
1234 10 digitsum. |
|||
"fe" 16 digitsum. |
|||
"f0e" 16 digitsum. |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre>1 |
|||
10 |
|||
29 |
|||
29</pre> |
|||
=={{header|jq}}== |
=={{header|jq}}== |