कलन संख्या का सूत्र: C_n = 2^n * n + 1। nवीं कलन संख्या खोजें।
बिट शिफ्ट का उपयोग करें: 1 << n = 2^n।
उदाहरण: n=2 → 2^2 * 2 + 1 = 9।
C++ कार्यान्वयन
#include <bits/stdc++.h>
using namespace std;
unsigned get_cullen(unsigned n) {
return (1 << n) * n + 1;
}
int main() {
int n = 2;
cout << get_cullen(n);
return 0;
}
आउटपुट
9