Given a number, find sum of its digits.
Input : n = 687 Output : 21 Input : n = 12 Output : 3
How to compute in single line?
Please refer complete article on Program for Sum the digits of a given number for more details!
My Personal Notes arrow_drop_up
- Java Program to Reverse a Number and find the Sum of its Digits Using do-while Loop
- Java Program to Extract Last two Digits of a Given Year
- Java Program to Extract Digits from A Given Integer
- Java Program to Increment by 1 to all the Digits of a given Integer
- Java Program to Check if all digits of a number divide it
- Java Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- Java Program for Difference between sums of odd and even digits
- TCS Coding Practice Question | Sum of Digits of a number
- Java Program for How to check if a given number is Fibonacci number?
- Check if the given decimal number has 0 and 1 digits only
- Java Program to Find sum of even factors of a number
- Java Program to Find minimum sum of factors of number
- Java Program for Number of elements with odd factors in given range
- Java Program for efficiently print all prime factors of a given number
- Java Program for Number of jump required of given length to reach a point of form (d, 0) from origin in 2D plane
- Java ArrayList to print all possible words from phone digits
- How to check if string contains only digits in Java
- Java Program to Find the Number Occurring Odd Number of Times
- Java Program to Convert a Decimal Number to Binary & Count the Number of 1s
- Java Program for Program to calculate area of a Tetrahedron