mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Improved code readability and code quality (#4663)
* Fixed Small typos :-) * Update BufferedReader.java * Made the following changes : * Improved readability of files and removed gramatical errors. * Implemented data assigning instead of manually calling arr.ylength in several instances like FindMax, FindMaxRecursion etc. * Removed unwanted params from several files * Implemented Math methods in files math/FindMinRecursion.java and FindMaxRecursion.java * Update src/main/java/com/thealgorithms/maths/FindMinRecursion.java --------- Co-authored-by: Debasish Biswas <debasishbsws.dev@gmail.com>
This commit is contained in:
@@ -51,17 +51,17 @@ class DigitalRoot {
|
||||
}
|
||||
}
|
||||
|
||||
// This function is used for finding the sum of digits of number
|
||||
// This function is used for finding the sum of the digits of number
|
||||
public static int single(int 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
|
||||
}
|
||||
} // 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
|
||||
} // n / 10 is the number obtained after removing the digit one by one
|
||||
// The 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
|
||||
* Time Complexity: O((Number of Digits)^2) Auxiliary Space Complexity:
|
||||
* O(Number of Digits) Constraints: 1 <= n <= 10^7
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user