Advertisement
YORDAN2347

SumOfNums

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