Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class AstrologDigits
- {
- static void Main()
- {
- ulong astroSum = 0;
- while (true)
- {
- int chDigit = Console.Read();
- if (chDigit == (int)'\n' || chDigit == (int)'\r' || chDigit == -1)
- {
- break;
- }
- if (chDigit >= '0' && chDigit <= '9')
- {
- ulong digit = (ulong)chDigit - (ulong)'0';
- astroSum = astroSum + digit;
- }
- }
- while (astroSum > 9)
- {
- ulong tempAstroSum = 0;
- while (astroSum > 0)
- {
- ulong lastDigit = astroSum % 10;
- tempAstroSum = tempAstroSum + lastDigit;
- astroSum = astroSum / 10;
- }
- astroSum = tempAstroSum;
- }
- Console.WriteLine(astroSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment