Skip to content

Instantly share code, notes, and snippets.

@ASPSUNIL
ASPSUNIL / 01_cbf-01_isPowerOfTwo.js
Last active January 20, 2024 16:57
Module 2: Coding Challenges Design and Analysis of Algorithms
/* Sarah, a dedicated mathematician and puzzle enthusiast, stumbled upon an intriguing challenge while delving into her research.
She contemplated the creation of an IsPowerOfTwo function, which takes a positive integer n as an argument and aims to discern whether
the given number qualifies as a power of two. In mathematical terms, an integer n is deemed a power of two if it can be represented as 2
raised to an integer exponent. For example, 8 is a power of two because it can be written as 2³.
*/
module.exports = { isPowerOfTwo };
function isPowerOfTwo(n) {