Thousand Separator

EasyStringMath

Description

Given an integer n, add a dot (".") as the thousands separator and return it as a string. For example, 1234567 becomes "1.234.567".

Examples

Input:n = 987
Output:"987"
Explanation:

No separator needed.

Input:n = 0
Output:"0"
Explanation:

Zero is a single digit, so no thousand separator is needed.

Input:n = 50000
Output:"50.000"
Explanation:

The number has 5 digits, so a dot separator is placed before the last 3 digits to separate thousands.

Constraints

  • 0 ≤ n ≤ 2³¹ - 1

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.