Advertisement
liwgfr

Untitled

Sep 4th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.28 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 = String.valueOf(n).chars().map(x -> x - '0').sum();
  8.         System.out.println(sum);
  9.     }
  10. }
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement