Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

2 multiples

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 :: using automapper without dependency injection 
Java :: hadoop fs get size of directory java 
Java :: heap vs string constant pool 
Java :: java-util of geofence polygon 
Java :: how to add a note in java 
Java :: castle stones java qn 
Java :: javafx stage always on top 
Java :: reference value in array list java syntax 
Java :: java equivalent of pythons getattr 
Java :: java.applet defines how many interfaces 
Java :: detecting battery charging android 
Java :: linux mint switch language 
Java :: Meeting time: Merging Ranges (return) 
Java :: Duplicate class android.support.v4.os.ResultReceiver$MyRunnable 
Java :: Java int Keyword 
Java :: como codificar pilas en java creeper 
Java :: set background drawable programmatically android 
Java :: cypher query having multiple values 
Java :: Eclipse find/replace pluggin 
Java :: java arduino 
Java :: Rotate array to left k cells python 
Java :: como llamar a un metodo static en java 
Java :: Mirror Inverse Program in java 
Java :: java add backslash into string 
Java :: quitar letras repetidas de una palabra en java 
Java :: print string in reverse order using recursion java 
Java :: pgzint install windows 10 
Java :: thymeleaf Expression Object dialects 
Java :: Java TestNG Data provider Provider with multiple variables 
Java :: fibonacci java 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =