Skip to content
Open
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
11 changes: 11 additions & 0 deletions leet_code_problems/addDigits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down