Advertisement
sexecutora

Untitled

Jul 15th, 2019
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Numerics;
  3. using System.Linq;
  4. using System;
  5.  
  6. namespace CroockedDIgits
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12.  
  13. List<decimal> n = Console.ReadLine().Split('.').Select(decimal.Parse).ToList();
  14.  
  15. string digits = string.Join("", n);
  16.  
  17. Int64 number = Math.Abs(Int64.Parse(digits));
  18.  
  19. Int64 sum = 0;
  20.  
  21. while (number != 0)
  22. {
  23.  
  24. sum += number % 10;
  25.  
  26. number /= 10;
  27.  
  28. if (sum > 9)
  29. {
  30. sum = sum - 9;
  31. continue;
  32. }
  33. }
  34.  
  35. Console.WriteLine(sum);
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement