Help with interview question

Revision en3, by kn0ppers, 2021-12-24 22:17:20

Hi all,

recently i attended a job interview where i got the following question:

Given x and y, find the number of integers such that for z in [1..x] z & y > 0?

Is there a faster way to compute this other than iterating through all the ints from [1..x]? Is there some sort of trick to compute this directly? I appreciate anyone taking the time to give me hints/tricks to compute this.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English kn0ppers 2021-12-24 22:17:20 2 Tiny change: 'such that for `z in [1..x' -> 'such that `for z in [1..x'
en2 English kn0ppers 2021-12-24 22:16:48 26
en1 English kn0ppers 2021-12-24 22:14:29 430 Initial revision (published)