Skip to content

Commit 95e927c

Browse files
committed
documentation added
1 parent fc44a87 commit 95e927c

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/main/java/com/thealgorithms/maths/UniformNumbers.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
package com.thealgorithms.maths;
22

3+
/**
4+
* A positive integer is considered uniform if all
5+
* of its digits are equal. For example, 222 is uniform,
6+
* while 223 is not.
7+
* Given two positive integers a and b, determine the
8+
* number of uniform integers between a and b.
9+
*/
310
public final class UniformNumbers {
4-
511
// Private constructor to prevent instantiation of the utility class
612
private UniformNumbers() {
713
// Prevent instantiation
814
}
9-
15+
/**
16+
* This function will find the number of uniform numbers
17+
* from 1 to num
18+
* @param num upper limit to find the uniform numbers
19+
* @return the count of uniform numbers between 1 and num
20+
*/
1021
public static int uniformNumbers(int num) {
1122
String numStr = Integer.toString(num);
1223
int uniformCount = (numStr.length() - 1) * 9;
@@ -20,7 +31,13 @@ public static int uniformNumbers(int num) {
2031

2132
return uniformCount;
2233
}
23-
34+
/**
35+
* This function will calculate the number of uniform numbers
36+
* between a and b
37+
* @param a lower bound of range
38+
* @param b upper bound of range
39+
* @return the count of uniform numbers between a and b
40+
*/
2441
public static int countUniformIntegers(int a, int b) {
2542
if (b > a && b > 0 && a > 0) {
2643
return uniformNumbers(b) - uniformNumbers(a - 1);

0 commit comments

Comments
 (0)