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-java Show documentation
Show all versions of leetcode-in-java Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
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;
}
}