Skip to content

Instantly share code, notes, and snippets.

@koistya
Created August 14, 2014 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koistya/d52271c589e7fb35a224 to your computer and use it in GitHub Desktop.
Save koistya/d52271c589e7fb35a224 to your computer and use it in GitHub Desktop.
public static string Fun(int num)
{
if (num == 0)
{
return "0";
}
var result = new StringBuilder();
var count = 0;
while (num > 0 && ++count > 0)
{
var digit = num % 10;
num = (num - digit) / 10;
result.Insert(0, digit);
if (num > 0 && count % 3 == 0)
{
result.Insert(0, ",");
}
}
return result.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment