sumdigits.frink

View or download sumdigits.frink in plain text format


// Finds the sum of digits in a number.

sumDigits[n] :=
{
   str = "$n"
   sum = 0
   for c = array[char[str]]
      sum = sum + c - char["0"]

   return sum
}


View or download sumdigits.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 17646 days, 9 hours, 36 minutes ago.