將遞迴式 a1 = 2, an = an-1 + 2n - 2 展開。
Solve the recursive equation a1 = 2, an = an-1 + 2n - 2.

ZeroJudge Link (Zh)

#include <stdio.h>

main() {
  int num;
  while (scanf("%d", &num) != EOF) {
    printf("%d\n", 2 + num * (num + 1) - 2 * num);
  }
  return 0;
}