Advertisement
liwgfr

Untitled

Sep 4th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner in = new Scanner(System.in);
  6.         int n = in.nextInt();
  7.         int sum = 0;
  8.         while (n % 10 != 0) {
  9.             sum += n % 10;
  10.             n /= 10;
  11.         }
  12.         System.out.println(sum);
  13.     }
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement