Adding Commas
InterviewTime limit1sMemory limit128 MB
Insert a comma every three digits from the right in a given integer and print the formatted number.
- Level
Easy3 of 10
- Topics
- String, Implementation, Math
- Solved
- No attempts yet
Problem
Large numbers are much easier to read when a comma is inserted every three digits. For example, 153920529 can be written as 153,920,529.
Given an integer , write a program that inserts a comma every three digits, counting from the right, and prints the result.
Input
The first line contains an integer ().
Output
Print on a single line with a comma separating every group of three digits, counting from the right. The leftmost group has no leading comma.