[swexpert] 2019. 더블더블 (java, D1)

728x90
반응형

Math.power는 실수형을 반환하므로 int로 치환한 후 출력해주면 된다

 

import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		for (int i = 0; i <= n; i++) {
			System.out.print((int)Math.pow(2,i)+" ");
		}

	}

}
728x90
반응형
TAGS.

Comments