> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/s/sum_digits_of_an_integer.md).

# Sum digits of an integer

```ruby
func Σ(String str, base=36) {
    str.chars.map{ Num(_, base) }.sum
}
 
<1 1234 1020304 fe f0e DEADBEEF>.each { |n|
    say "Σ(#{n}) = #{Σ(n)}"
}
```

#### Output:

```
Σ(1) = 1
Σ(1234) = 10
Σ(1020304) = 10
Σ(fe) = 29
Σ(f0e) = 29
Σ(DEADBEEF) = 104
```
