Untitled
unknown
java
a year ago
369 B
7
Indexable
import java.util.Scanner; public class P1 { public static int Sol(int n, int x) { int s = 0; for (int i = 0; i <= n; i++) { s += Math.pow(x, 2 * i + 1); } return s; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int n = sc.nextInt(); System.out.println(Sol(n, x)); } }
Editor is loading...
Leave a Comment