2^24 - Challenge - Java

import java.lang.Math;

public class Main {

	public static void main(String[] args) {
		
//		w/o Math-function:
		int power = 2;
		int result = 0;
		
		for(int i = 1; i < 24; i++) {
			
			result = 2 * power;
			power = result;
		}
		System.out.println(result);
		
		
//		with Math-funtion:
		
		System.out.println(Math.pow(2, 24)); 
		
/**
 * Note: xEy = x*10^y
 */

	}
}

OUTPUT
2^24

I really struggled with the “w/o Math-function”-method… even though it’s pretty simple, I was thinking too complicated :smiley:

:clap:

Privacy & Terms