Created
August 14, 2014 13:02
-
-
Save koistya/d52271c589e7fb35a224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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