Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

2 multiples recursion

import java.util.Scanner;

public class multipied {
    public static Scanner scanner = new Scanner (System.in);
    public static void main(String[] args) {
        System.out.println("Enter int");
        int n = scanner.nextInt();
        int sum = 1;
        System.out.println("For loop");
        for(int i = 0 ; i < n ; ++i ){
            if(n == 0){
                System.out.println(sum+'
');
                break;
            }
            sum*=2;
        }
        System.out.println(sum);
        int r = multipied(n);
        System.out.println("
Recursive");
        System.out.println(r);
        ;

    }

    public static  int multipied(int n){

        if(n ==0)
            return 1;

        return 2 * multipied(n-1);
    }

}


Comment

PREVIOUS NEXT
Code Example
Java :: get historical data from the past to the present yahoo finance api 
Java :: getcokor from drawable in java android studio 
Java :: Program to read base and power and then calculate result of that expression using recursion in java 
Java :: RNGestureHandlerButtonViewManager.java uses or overrides a deprecated API 
Java :: Janaaa_Sa 
Java :: java how to make a recrussive boolean function 
Java :: how to install java jdk 8 on ubuntu 20.04 for spark 
Java :: pgzint install windows 10 
Java :: session-less control using java 
Java :: 1 2 1 3 2 1 4 3 2 1 3 2 1 2 1 1 java 
Java :: java reverse serach 
Java :: nullpointer extension 
Java :: how to run javac xlint 
Java :: change replication factor hadoop cluster command 
Java :: Java Insert Elements to TreeSet 
Java :: java ternärer operator 
Java :: what is void in java 
Java :: They say that they have to create an instance to their application. What does it mean? 
Java :: how to easy get 240 fps in minecraft java 
Java :: Java Enable assertion in class names 
Java :: concludes() Method 
Java :: spring component 
Java :: Caused by: android.view.InflateException: Binary XML file line 
Java :: multidimensional arrays java 
Java :: multiple string java 
Java :: javafx access fxml elements 
Java :: can you use java in unity 
Java :: connection data base java code 
Java :: round off and round up 
Java :: bootstrap messages red 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =