← Back to challenges

Curzon Numbers

JavaScriptHardnumbersmathvalidation

Instructions

In this challenge, establish if a given integer num is a Curzon number. If 1 plus 2 elevated to num is exactly divisible by 1 plus 2 multiplied by num, then num is a Curzon number.

Given a non-negative integer num, implement a function that returns true is num is a Curzon number, or false if it's not.

Examples

isCurzon(5) ➞ true
// 2 ** 5 + 1 = 33
// 2 * 5 + 1 = 11
// 33 is a multiple of 11

isCurzon(10) ➞ false
// 2 ** 10 + 1 = 1025
// 2 * 10 + 1 = 21
// 1025 is not a multiple of 21

isCurzon(14) ➞ true
// 2 ** 14 + 1 = 16385
// 2 * 14 + 1 = 29
// 16385 is a multiple of 29

Notes

Note for JavaScript version: in this challenge, you must use BigInt objects instead of numbers.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Is the Number a Prime? (with a twist)