Advertisement
MartinTopchiev

Crooked Digits

Nov 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Numerics;
  4.  
  5. namespace CroockedDigits
  6.  
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string input = Console.ReadLine();
  13. string clearedInput = input.Replace(".", "").Replace("-" , "");
  14. BigInteger parseInput = long.Parse(clearedInput);
  15. BigInteger n = parseInput;
  16. BigInteger sum = 0;
  17.  
  18. while (n > 0 || sum > 9)
  19. {
  20. if (n == 0)
  21. {
  22. n = sum;
  23. sum = 0;
  24. }
  25. sum += n % 10;
  26. n = n / 10;
  27. }
  28. Console.WriteLine(sum);
  29. //bie mi IR na nqkoi ot testovete
  30. //test s Biginteger
  31. //pak pishe IRA
  32.  
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement