There's a cool magic trick that works using the power of binary. The effect of the trick is as follows:
An audience member chooses some natural number in the range of
1 to xwhere x is chosen by the magician.
The magician hands the audience member some special cards. Each card contains some numbers from
1 to x.
The audience member selects the cards which contain their number.
Almost instantly, the magician can determine the original number selected.
The numbers used for the cards are determined based on binary place value. Each card is first labeled with a power of 2. The first card becomes 1, the second becomes 2, the third becomes 4, and so on.
From now on, I will refer to
card n as the card labeled with
To determine whether a number
k is on card
n, determine whether k in binary has at 1 at place value n. Consider the numbers
K in binary is
1101. The second digit (n=4) is 1, so
k=13, n=4 is a valid combination.
Given two natural numbers
0 < n < 128 and
0 < k < 128, determine whether
n appears on card
k. Any reasonable input and output is allowed. Standard loopholes are banned.
This is code-golf, so the fewest bytes wins.