[프로그래머스 Lv0.] 세균증식(JAVA)

gayoung·2023년 2월 10일
0

알고리즘

목록 보기
19/50
post-thumbnail

1. 문제

문제 설명


2. 풀이 과정

내가 생각한 진행 과정

  • n제곱 구하기 -> t번째까지 계속 n을 곱해주기

최종 코드

public class Solution {

    public int solution(int n, int t) {

        int answer = n;
        for (int i = 0; i < t; i++) {
            answer *= 2;
        }
        return answer;
    }
}

0개의 댓글

Powered by GraphCDN, the GraphQL CDN