From 7077809d261e83e33c2114eb3197aaf5c54b3557 Mon Sep 17 00:00:00 2001 From: Praveen Toppo Date: Wed, 29 Sep 2021 23:14:53 +0530 Subject: [PATCH] fix: added one more approach to solve the problem Digital root method --- leet_code_problems/addDigits.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/leet_code_problems/addDigits.cpp b/leet_code_problems/addDigits.cpp index 8958217..a8f4534 100644 --- a/leet_code_problems/addDigits.cpp +++ b/leet_code_problems/addDigits.cpp @@ -30,6 +30,17 @@ int sumDigits( int num ) { } return num % 9; } +/* +You can find the sum of digits by using digital root method. + +int sumDigits(int num) +{ + if(num<10) + return num; + return (num%9==0 ? 0 : num%9); +} + +*/ int main() { int n;