- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to find Cullen Number in C++
In this tutorial, we will be discussing a program to find Cullen Number.
For this we will be provided with an integer. Our task is to find the cullen number at that position using the formula −
2n* n + 1
Example
#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; }
Output
9
Advertisements