Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

add digits java

    public static int sumDigits(int number){
        if (number < 10) return -1;
        int sum = 0;
        while (number > 10){
             sum += number % 10;
            number /= 10;
        }
        return sum + number;
Comment

add digits java


public static void main(String[] args) {
        int num = 321;
        int sum = 0;
        while (num > 0) {
            sum = sum + num % 10;
            num = num / 10;
        }
        System.out.println(sum); 
}

Comment

sum of digits java

   public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int num = input.nextInt();

        int sum = 0;

        while (num > 0) {
            sum += num % 10;
            num /= 10;
        }
        System.out.println("sum of digits: " + sum);
    }
Comment

PREVIOUS NEXT
Code Example
Typescript :: ngx-file-drop allow only image or pdf 
Typescript :: python convert a csv to a tsv 
Typescript :: loc with multiple conditions 
Typescript :: print elements of unordered set c++ 
Typescript :: typescript break for each 
Typescript :: Simple Bulk insert TSQL csv 
Typescript :: select column values from array typescript 
Typescript :: whats my country 
Typescript :: actionscript 
Typescript :: React.ComponentProps<T 
Typescript :: disable sonar rule in code 
Typescript :: avoid intertwining subplots in python 
Typescript :: ternary operator in typescript 
Typescript :: typescript get class name 
Typescript :: DAX check if value exists in another table 
Typescript :: locking value of cell 
Typescript :: typescript arr numbers and strings 
Typescript :: npm run serve https 
Typescript :: typescript get full path of file 
Typescript :: replace element in array typescript 
Typescript :: how to clear known_hosts in ssh 
Typescript :: counts of unique values in rows of given 2D array numpy 
Typescript :: conditional styled components with media query 
Typescript :: typescript null and undefined check 
Typescript :: typescript http get attach headers 
Typescript :: validation minlength angular 
Typescript :: typescript dynamic dict 
Typescript :: ipywidgets hide widget 
Typescript :: go Array’s length is part of its type. 
Typescript :: mailbox exists c# 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =