1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-10 00:09:06 +01:00

problems(rs): add “258. Add Digits”

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2023-04-27 21:01:46 +02:00
parent 0d66103a07
commit ae2082c39c
Signed by: mfocko
GPG key ID: 7C47D46246790496

13
problems/add-digits.rs Normal file
View file

@ -0,0 +1,13 @@
impl Solution {
pub fn add_digits(num: i32) -> i32 {
if num == 0 {
return 0;
}
if num % 9 == 0 {
return 9;
}
num % 9
}
}