Tìm số hạng thứ N của dãy: 3, 12, 29, 54, 86, 128, 177, 234, ...
Công thức chung
Tn = 4n² - 3n + 2
Ví dụ minh họa (C++)
#include <iostream>
#include <cmath>
using namespace std;
int nthTerm(int n) {
return 4 * pow(n, 2) - 3 * n + 2;
}
int main() {
int N = 4;
cout << nthTerm(N) << endl;
return 0;
}
Đầu ra
54