# Program to find Cullen Number

A Cullen Number is a number of the form is 2n * n + 1 where n is an integer. The first few Cullen numbers are 1, 3, 9, 25, 65, 161, 385, 897, 2049, 4609 . . . . . .
Examples:

```Input : n = 4
Output :65

Input : n = 0
Output : 1

Input : n = 6
Output : 161

```

## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Below is implementation of formula. We use bitwise left-shift operator to find 2n, then multiply the result with n and finally returns (1 << n)*n + 1.

## C++

 `// C++ program to find Cullen number ` `#include ` `using` `namespace` `std; ` ` `  `// function to find n'th cullen number ` `unsigned findCullen(unsigned n) ` `{ ` `    ``return` `(1 << n) * n + 1; ` `} ` ` `  `// Driver code ` `int` `main() ` `{ ` `    ``int` `n = 2; ` `    ``cout << findCullen(n); ` `    ``return` `0; ` `} `

## Java

 `// Java program to find Cullen number ` `import` `java.io.*; ` ` `  `class` `GFG { ` `    ``// function to find n'th cullen number ` `    ``static` `int` `findCullen(``int` `n) ` `    ``{ ` `        ``return` `(``1` `<< n) * n + ``1``; ` `    ``} ` ` `  `    ``// Driver code ` `    ``public` `static` `void` `main(String[] args) ` `    ``{ ` `        ``int` `n = ``2``; ` `        ``System.out.println(findCullen(n)); ` `    ``} ` `} ` ` `  `// This code is contributed by vt_m. `

## Python3

 `# Python program to  ` `# find Cullen number ` ` `  `# Function to calculate ` `# Cullen number ` `def` `findCullen(n): ` ` `  `    ``# Formula to calculate ` `    ``# nth Cullen number ` `     `  `    ``return` `(``1` `<< n) ``*` `n ``+` `1` ` `  `# Driver Code ` `n ``=` `2` `print``(findCullen(n)) ` ` `  `# This code is contributed ` `# by aj_36                  `

## C#

 `// C# program to find Cullen number ` `using` `System; ` ` `  `class` `GFG { ` `    ``// function to find n'th cullen number ` `    ``static` `int` `findCullen(``int` `n) ` `    ``{ ` `        ``return` `(1 << n) * n + 1; ` `    ``} ` ` `  `    ``// Driver code ` `    ``public` `static` `void` `Main() ` `    ``{ ` `        ``int` `n = 2; ` `        ``Console.WriteLine(findCullen(n)); ` `    ``} ` `} ` ` `  `// This code is contributed by vt_m. `

## PHP

 ` `

Output:

```9
```

Properties of Cullen Numbers:

1. Most of the Cullen Numbers are composite numbers.
2. n’th Cullen number is divisible by p = 2n – 1 if p is a prime number of the form 8k – 3.

This article is contributed by DANISH_RAZA. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Improved By : jit_t

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.