Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Numerics;
  10.  
  11. namespace CrockedDigits2
  12. {
  13. class Program
  14. {
  15. static void Main(string[] args)
  16. {
  17.  
  18. string n = Console.ReadLine();
  19. int result = 0;
  20.  
  21. do
  22. {
  23. result = 0;
  24.  
  25. foreach (char item in n)
  26. {
  27. if (Char.IsDigit(item))
  28. {
  29. result += (int)Char.GetNumericValue(item);
  30. }
  31. }
  32. n = result.ToString();
  33.  
  34. } while (n.Length > 1);
  35.  
  36. Console.WriteLine(result);
  37.  
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement