231. Power of Two

202409012130
tags: #math

var isPowerOfTwo = function(n) {
	if (n === 0) {
		return false;
	}
	if (n % 2 === 0) {
		return isPowerOfTwo(n / 2);
	}
	return n === 1;
};

Reference

https://leetcode.com/problems/power-of-two/