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