if the remainder after subtracting previous power of 2 is also a power of 2 then it can be expressed as 2 ^ x + 2 ^ y
var x = previousPowerOfTwo ( n ) ; var y = n - x ; if ( isPowerOfTwo ( y ) ) { document . write ( x + " " + y + " " ) ; return true ; } } return false ; }