#17294: c++遞迴解法


d10730416@gapps.fg.tp.edu.tw (Wendy Charng)


#include <iostream>
using namespace std;

int n, A(int);

int main() {
  while (cin >> n){
    cout << A(n) << endl;
  }
}

int A(int n){
  if (n == 1) return 2;
  else return A(n - 1) + 2 * n - 2;
}