Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SumOfThePowers {
- public static void main(String[] args) {
- Scanner reader = new Scanner(System.in);
- int i = 1;
- System.out.println("Type a number: ");
- int exp = Integer.parseInt(reader.nextLine());
- int result = (int)Math.pow(2, exp);
- while (i <= exp) {
- Math.pow(2, i);
- i++;
- }
- System.out.println("The result is " + result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement