Sum digits of an integer: Difference between revisions
Content added Content deleted
(Easylang) |
|||
Line 1,770: | Line 1,770: | ||
=={{header|EasyLang}}== |
=={{header|EasyLang}}== |
||
<syntaxhighlight lang="easylang"> |
<syntaxhighlight lang="easylang"> |
||
func sumdig s$ . |
|||
r = 0 |
|||
for c$ in strchars s$ |
for c$ in strchars s$ |
||
h = strcode c$ - 48 |
h = strcode c$ - 48 |
||
Line 1,779: | Line 1,778: | ||
r += h |
r += h |
||
. |
. |
||
return r |
|||
. |
. |
||
print sumdig "1" |
|||
print sumdig "1234" |
|||
print sumdig "fe" |
|||
print sumdig "f0e" |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||