import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { int n; Scanner sc = new Scanner(System.in); while (sc.hasNext()) { n = sc.nextInt(); BigInteger sum = new BigInteger("2"); while(n!=1){ sum = sum.multiply(BigInteger.valueOf(3)).subtract(BigInteger.ONE); n--; } System.out.println(sum); } } } |
Double click to view unformatted code.