Advertisement
martinvalchev

Powers of Two

Nov 21st, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3.  
  4. public class PowersofTwo {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int n = Integer.parseInt(scanner.nextLine());
  9.  
  10.         DecimalFormat df = new DecimalFormat("#.#####################");
  11.  
  12.         for (int i = 0; i <= n ; i++) {
  13.             System.out.printf("%s%n", df.format(Math.pow(2, i)));
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement