Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Solution {
- public static void main(String[] args) {
- System.out.println(sumDigitsInNumber(546));
- }
- public static int sumDigitsInNumber(int number) {
- //write your code here
- int sum = 0;
- while (number > 0){
- sum = sum + number % 10;
- number = number / 10;
- }
- return sum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement