ในบทช่วยสอนนี้ เราจะพูดถึงโปรแกรมค้นหา Cullen Number
สำหรับสิ่งนี้เราจะได้รับจำนวนเต็ม งานของเราคือการหาหมายเลขคัลเลนที่ตำแหน่งนั้นโดยใช้สูตร -
2n* n + 1
ตัวอย่าง
#include <bits/stdc++.h>
using namespace std;
//finding the nth cullen number
unsigned get_cullen(unsigned n){
return (1 << n) * n + 1;
}
int main(){
int n = 2;
cout << get_cullen(n);
return 0;
} ผลลัพธ์
9