Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Program to read base and power and then calculate result of that expression using recursion in java

public class Digit_Sum 
{
    public static void main(String[] args) 
    {
        int n = 1230;
        int result = digit_sum(n);
        System.out.println("Sum:"+result);
    }
    public static int digit_sum(int n)
    {
        int sum = n % 10;
        if(n == 0)
        {
            return 0;
        }
        else
        {
             return sum + digit_sum(n / 10);
        }
 
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: tests offline cypress 
Java :: RNGestureHandlerButtonViewManager.java uses or overrides a deprecated API 
Java :: jsp form upload file 
Java :: random number in java between 10 and 20 
Java :: ratespiel java 
Java :: How do you input numbers into an array? 
Java :: adding new field in existing kibana index using spark java 
Java :: collapse recycler view on new item click 
Java :: steps to accomplish jdbc connection in java 
Java :: java inetaddress workaround how to get localhost secure 
Java :: binomial heap implementation java 
Java :: Java Finding Extreme Values 
Java :: How can i stub Instant object using powermock 
Java :: Java’s generic programming does not apply to the primitive types. True or False? 
Java :: ordenar mapa de forma descendente java 
Java :: Java Get float, double and String Input 
Java :: java output formatting 
Java :: origin model color 
Java :: aws s3 client in java 
Java :: Uri/beecrowd problem no 1118 solution in Java 
Java :: priorityQueue peek java 
Java :: what is inheritance in java 
Java :: java recursion 
Java :: string split java 
Java :: how to check if array is full java 
Java :: Linked list implementation in Java source code 
Java :: spring cloud starter eureka client dependency 
Java :: java button with jpg image 
Java :: java forcing user to input int 
Sql :: codeigniter print last sql query 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =