sumdigits.frink

Download or view 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
}


Download or view 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 20145 days, 12 hours, 37 minutes ago.