Skip to content

Commit a5c09c2

Browse files
committed
Count Digits in number
1 parent e8f48c2 commit a5c09c2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.dev.number.operations;
2+
3+
public class DigitsCountInNumber {
4+
5+
public static int getDigitCountOf(int number){
6+
int count = 0;
7+
while (number != 0){
8+
number = number / 10;
9+
count++;
10+
}
11+
return count;
12+
}
13+
14+
public static void main(String[] args) {
15+
16+
int number = 1765712349;
17+
int digitCount = getDigitCountOf(number);
18+
System.out.println("digitCount = " + digitCount);
19+
20+
}
21+
}

0 commit comments

Comments
 (0)