Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f9efb72

Browse files
committed
Optimized the code: Have implemented the program to add the digits to the one digit.
1 parent dd4a4ec commit f9efb72

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/com/raj/AddDigits.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ public class AddDigits {
2727
public static void main(String[] args) {
2828
// Initialization.
2929
int num = 111;
30-
int sum = 0;
3130

3231
// Logic.
33-
sum = provideTotalToOneDigit(num);
32+
num = provideTotalToOneDigit(num);
3433

3534
// Display the result.
36-
System.out.println("The sum of the provided digit to the one digit is: " + sum);
35+
System.out.println("The sum of the provided digit to the one digit is: " + num);
3736
}
3837

3938
private static int provideTotalToOneDigit(int num) {

0 commit comments

Comments
 (0)