using System; using System.Linq; namespace Kumite { public class Problem { public static int SumDigitsOf(long integer) { long sum = 0; long m; while(Math.Abs(integer) > 0){ m = Math.Abs(integer%10); sum += m; integer /= 10; } return Convert.ToInt32(sum); } } }
- using System;
- using System.Linq;
- namespace Kumite
- {
- public class Problem
- {
- public static int SumDigitsOf(long integer)
- {
return Math.Abs(integer).ToString().Sum(digit => digit - '0');- long sum = 0;
- long m;
- while(Math.Abs(integer) > 0){
- m = Math.Abs(integer%10);
- sum += m;
- integer /= 10;
- }
- return Convert.ToInt32(sum);
- }
- }
- }