File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,18 @@ public static int digitalRoot(int n) {
2828 return result ;
2929 }
3030
31+ /**
32+ * Retains compatibility with the original Codewars API.
33+ *
34+ * @param n a non-negative integer
35+ * @return the digital root of {@code n}
36+ * @deprecated use {@link #digitalRoot(int)} instead
37+ */
38+ @ Deprecated
39+ public static int digital_root (int n ) {
40+ return digitalRoot (n );
41+ }
42+
3143 /**
3244 * Digital root is the recursive sum of all the digits in a number.
3345 * Given n, take the sum of the digits of n. If that value has more than one
Original file line number Diff line number Diff line change @@ -21,5 +21,6 @@ class DigitalRootTest {
2121 void shouldReduceNumberToSingleDigit (int value , int expected ) {
2222 assertEquals (expected , DigitalRoot .digitalRoot (value ));
2323 assertEquals (expected , DigitalRoot .digitalRootRecursiveStream (value ));
24+ assertEquals (expected , DigitalRoot .digital_root (value ));
2425 }
2526}
You can’t perform that action at this time.
0 commit comments