ในบทช่วยสอนนี้ เราจะพูดถึงโปรแกรมค้นหาคำ N-th ของซีรีส์ 0, 7, 8, 33,51, 75, 102, 133...
สำหรับเรื่องนี้เราจะมีเลขเด็ดมาให้ งานของเราคือค้นหาคำศัพท์สำหรับชุดที่กำหนด ณ ตำแหน่งนั้น
ตัวอย่าง
#include <iostream>
#include <math.h>
using namespace std;
//calculating nth term of series
int nthTerm(int n) {
return 2 * pow(n, 2) + n - 3;
}
int main() {
int N = 4;
cout << nthTerm(N) << endl;
return 0;
} ผลลัพธ์
33