หาพจน์ที่ N ของอนุกรม: 0, 10, 30, 60, 99, 150, 210, 280, ...
ตัวอย่าง: N = 4 → 60
วิธีแก้ปัญหา (Quadratic Formula)
สูตรพจน์ที่ n:
Tn = 5×n² - 5×n
ตัวอย่างโค้ด C++
#include <iostream>
#include <cmath>
using namespace std;
int nthTerm(int n) {
return 5 * pow(n, 2) - 5 * n;
}
int main() {
int N = 4;
cout << nthTerm(N) << endl;
return 0;
}
Output
60