using System;
namespace restless
{
class Program
static int sumDigits(int n)
return n > 9 ? n % 10 + sumDigits(n / 10) : n;
}
static void Main(string[] args)
int num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(sumDigits(num));
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
using System;
namespace restless
{
class Program
{
static int sumDigits(int n)
{
return n > 9 ? n % 10 + sumDigits(n / 10) : n;
}
static void Main(string[] args)
{
int num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(sumDigits(num));
}
}
}