fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. int value = 601511616;
  9. List<int> digits = new List<int>();
  10.  
  11. while (value > 0)
  12. {
  13. digits.Add(value % 10);
  14. value /= 10;
  15. }
  16.  
  17. digits.Reverse(); // Values has been inserted from least significant to the most
  18.  
  19. Console.WriteLine("Count of digits: {0}", digits.Count);
  20.  
  21. for (int i = 0; i < digits.Count; i++)
  22. {
  23. if (i > 0 && i % 3 == 0) Console.Write(","); // Insert comma after every 3 digits
  24. Console.Write("{0}", digits[i]);
  25. }
  26. }
  27. }
Success #stdin #stdout 0.04s 23976KB
stdin
Standard input is empty
stdout
Count of digits: 9
601,511,616