-
문제 19 - 거듭제곱 출력알고리즘/알고리즘 기초 100제 2020. 8. 20. 10:32
문제 : 5,3 입력시 5의 3승, = 125 출력.
import java.util.*; public class Youtube19 { /* n^m 5^3 = 5*5*5 = 125 */ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); System.out.print("Input the n : "); int n = scanner.nextInt(); System.out.print("Input the m : "); int m = scanner.nextInt(); int result = 1; for(int i=1; i<=m; i++){ result *= n; } System.out.print("result : " + result); } }
'알고리즘 > 알고리즘 기초 100제' 카테고리의 다른 글
문제 21번 - 중복된 수 제거 후 출력 (0) 2020.09.21 문제 20번 - 369 게임 (0) 2020.09.21 문제18 - 별출력 (0) 2020.08.20 문제 17 - 별출력2 (0) 2020.08.09 문제16 - 별출력 (0) 2020.08.09