We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e97b705 commit 2684df3Copy full SHA for 2684df3
1 file changed
src/codeup100/c1090.java
@@ -7,17 +7,19 @@ public static void main(String[] args) {
7
String[] nums = sc.nextLine().split(" ");
8
sc.close();
9
10
- int a = Integer.parseInt(nums[0]);
11
- int r = Integer.parseInt(nums[1]);
12
- int n = Integer.parseInt(nums[2]);
+ int a = Integer.parseInt(nums[0]); //시작값
+ int r = Integer.parseInt(nums[1]); //등비
+ int n = Integer.parseInt(nums[2]); //몇번째인지 나타내는 숫자
13
14
- // int에 최종 출력값이 들어가지 않으므로 long으로 만든다.
+ // int에 최종 출력값이 들어가지 않으므로 long으로 만든다.
15
// 10 10 10 => 10000000000
16
+ //등비임으로 제곱메서드로 해결
17
18
long sum=0;
19
for(int i=0; i<n ; i++){
20
sum = (long) (a*Math.pow(r, i));
21
}
22
+
23
System.out.println(sum);
24
25
0 commit comments