# Program to find Cullen Number

A Cullen Number is a number of the form is 2^{n} * 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

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

## C++

`// C++ program to find Cullen number ` `#include <bits/stdc++.h> ` `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; ` `} ` |

*chevron_right*

*filter_none*

## 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. ` |

*chevron_right*

*filter_none*

## 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 ` |

*chevron_right*

*filter_none*

## 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. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to ` `// find Cullen number ` ` ` `// function to find n'th ` `// cullen number ` `function` `findCullen(` `$n` `) ` `{ ` ` ` `return` `(1 << ` `$n` `) * ` `$n` `+ 1; ` `} ` ` ` ` ` `// Driver code ` ` ` `$n` `= 2; ` ` ` `echo` `findCullen(` `$n` `); ` ` ` `// This code is contributed by ajit ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

9

**Properties of Cullen Numbers:**

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

**Reference: **https://en.wikipedia.org/wiki/Cullen_number

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.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

## Recommended Posts:

- Program to find the Nth number of the series 2, 10, 24, 44, 70.....
- Program to find Star number
- Program to find the number of men initially
- Program to find the Nth Harmonic Number
- Program to find the nth Kynea number
- Program to find the Hidden Number
- C program to find Decagonal Number
- Program to find number of squares in a chessboard
- Program to find last two digits of Nth Fibonacci number
- Program to find last digit of n'th Fibonnaci Number
- Program to find number of solutions in Quadratic Equation
- Program to find the number of region in Planar Graph
- Program to find remainder when large number is divided by r
- Program to find remainder when large number is divided by 11
- Program to find total number of edges in a Complete Graph