코딩 테스트
[프로그래머스/JS] 세균증식
jhlee_
2022. 10. 3. 17:40
링크
https://school.programmers.co.kr/learn/courses/30/lessons/120910
알아야할 내용
거듭제곱
1. Math.pow()
2. 거듭제곱 연산자 **
를 사용
**
는 Math.pow()와 동알하지만 BigInt도 가능- Math.pow(base, exponent)
- base 밑
- exponent 제곱하기 위한 지수 값
- 제곱근은 Math.sqrt()를 사용하자. 주어진 숫자에 루트를 씌움. ex) Math.squrt(9) // 3
// 연산자 **
2 ** 3 // 8
10 ** -1 // 0.1
// Math.pow()
Math.pow(2, 3) // 8
Math.pow(4, 0.5) // 2
소스코드
function solution(n, t) {
return n * ( 2 ** t);
}
728x90