#!/usr/bin/ruby

#
## https://rosettacode.org/wiki/Sum_digits_of_an_integer
#

func Σ(String str, base=36) {
    str.chars.map{ Num(_, base) }.sum
}

<1 1234 1020304 fe f0e DEADBEEF>.each { |n|
    say "Σ(#{n}) = #{Σ(n)}"
}
