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 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 Program to Find the Number Occurring Odd Number of Times
- Java ArrayList to print all possible words from phone digits
- How to check if string contains only digits in Java
- Java Program for Program to calculate area of a Tetrahedron
- Java Program for Program to find area of a circle
- Java Program for Program for array rotation
- Java Program for Range sum queries without updates
- Java Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Java Program for cube sum of first n natural numbers