g0201_0300.s0258_add_digits.Solution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java17 Show documentation
Show all versions of leetcode-in-java17 Show documentation
Java Solution for LeetCode algorithm problems, continually updating
package g0201_0300.s0258_add_digits;
// #Easy #Math #Simulation #Number_Theory
public class Solution {
public int addDigits(int num) {
if (num == 0) {
return 0;
}
if (num % 9 == 0) {
return 9;
}
return num % 9;
}
}