ในบทช่วยสอนนี้ เราจะพูดถึงโปรแกรมค้นหาคำ N-th ของชุดที่ 3, 12, 29, 54, 86, 128, 177, 234, …..
สำหรับสิ่งนี้เราจะได้รับหมายเลข งานของเราคือค้นหาคำศัพท์สำหรับซีรีส์ที่กำหนดในตำแหน่งนั้น ๆ
ตัวอย่าง
#include <iostream>
#include <math.h>
using namespace std;
//calculating nth term of given series
int nthTerm(int n) {
return 4 * pow(n, 2) - 3 * n + 2;
}
int main() {
int N = 4;
cout << nthTerm(N) << endl;
return 0;
} ผลลัพธ์
54