Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/kyu6/DigitalRoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public static int digitalRoot(int n) {
return result;
}

/**
* Retains compatibility with the original Codewars API.
*
* @param n a non-negative integer
* @return the digital root of {@code n}
* @deprecated use {@link #digitalRoot(int)} instead
*/
@Deprecated
public static int digital_root(int n) {
return digitalRoot(n);
}

/**
* Digital root is the recursive sum of all the digits in a number.
* Given n, take the sum of the digits of n. If that value has more than one
Expand Down
1 change: 1 addition & 0 deletions src/test/java/kyu6/DigitalRootTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
void shouldReduceNumberToSingleDigit(int value, int expected) {
assertEquals(expected, DigitalRoot.digitalRoot(value));
assertEquals(expected, DigitalRoot.digitalRootRecursiveStream(value));
assertEquals(expected, DigitalRoot.digital_root(value));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note test

Invoking
DigitalRoot.digital_root
should be avoided because it has been deprecated.
Comment thread
krotname marked this conversation as resolved.
}
}