sum the digits of a number

public CheckSum {


public static void main (String []args){

System.out.println(digitSum(45));

public static int digitSum(int number) {
		
	int sum = 0;
         
        while (number != 0)
        {
            sum = sum + number % 10;
            number = number/10;
        }
     
    return sum;
	}
}
}
build mobile apps in abuja

Check if a given number is perfect square in Java

Author

Leave a Reply

Your email address will not be published. Required fields are marked *