Cho số N. Tìm số hạng thứ N của dãy: 3, 5, 21, 51, 95, 153, ...
Công thức chung
Tn = 7n² - 19n + 15
Ví dụ
N = 6 → 153
N = 7 → 225
Ví dụ minh họa (C++)
#include <iostream>
using namespace std;
int findNTerm(int N) {
int nthTerm = (7 * (N * N)) - (19 * N) + 15;
return nthTerm;
}
int main() {
int N = 7;
cout << N << "th term of the series is " << findNTerm(N);
return 0;
}
Đầu ra
7th term of the series is 225