Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@ -39,8 +39,7 @@ package com.thealgorithms.maths;
class DigitalRoot {
public static int digitalRoot(int n) {
if (single(n) <= 9) // If n is already single digit than simply call single method and return the value
{
if (single(n) <= 9) { // If n is already single digit than simply call single method and return the value
return single(n);
} else {
return digitalRoot(single(n));
@ -49,17 +48,15 @@ class DigitalRoot {
// This function is used for finding the sum of digits of number
public static int single(int n) {
if (n <= 9) // if n becomes less than 10 than return n
{
if (n <= 9) { // if n becomes less than 10 than return n
return n;
} else {
return (n % 10) + single(n / 10); // n % 10 for extracting digits one by one
return (n % 10) + single(n / 10); // n % 10 for extracting digits one by one
}
} // n / 10 is the number obtainded after removing the digit one by one
} // n / 10 is the number obtainded after removing the digit one by one
// Sum of digits is stored in the Stack memory and then finally returned
}
/**
* Time Complexity : O((Number of Digits)^2) Auxiliary Space Complexity :
* O(Number of Digits) Constraints : 1 <= n <= 10^7