# The Binary Card Trick

A magician has six specially designed cards, each with thirty-two numbers (see below). Each of the numbers is between 1 and 63. A volunteer from the audience is selected and asked to choose one of the numbers. While the magician turns his back a volunteer from the audience shows the others in the audience which number she has chosen. The magician then asks the volunteer to hand him all of the cards that have her chosen number written on it. Immediately the magician reveals the chosen number. Here are the magician’s cards (and here's a set you can print off easily):

 Card 1 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 Card 2 4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 36 37 38 39 44 45 46 47 52 53 54 55 60 61 62 63 Card 3 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 40 41 42 43 44 45 46 47 56 57 58 59 60 61 62 63 Card 4 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 Card 5 2 3 6 7 10 11 14 15 18 19 22 23 26 27 30 31 34 35 38 39 42 43 46 47 50 51 54 55 58 59 62 63 Card 6 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

How does he do it? Do you notice anything special about the numbers on the cards? Take some time to study the cards before reading on.

## How the Magician Does the Trick

Remember that a number between 1 and 63 has been (secretly) chosen, and that the magician is then been handed those cards that contain the secret number. The magician then immediately reveals the secret number. How does he do it? He simply adds up the numbers that appear first (the upper-left-hand number) on the card. As an example, suppose the number 51 is chosen. It appears on the cards starting with numbers 16,1,2, and 32. The sum of these numbers (1+2+16+32) is, of course, 51. Try this with a few more numbers and check that the sums always add to the original number.

Notice that all of the numbers appearing first on the cards are powers of 2: $1=2^{0},$ $2=2^{1},$ $4=2^{2},$ etc, up to $32=2^{5}.$ This is because we are using binary, or base-2, numbers to make up the cards.

Binary, or base-2, numbers are numbers based on powers of two, just as our decimal, or base-10, numbers are based on powers of ten. Recall that the decimal number 6351 really means $6\times 10^{3}+3\times 10^{2}+5\times 10+1.$ Binary numbers work in exactly the same way, except that they use powers of two rather than ten. So the binary number 10011 means $1\times 2^{4}+0\times 2^{3}+0\times 2^{2}+1\times 2^{1}+1\times 1,$ or 16+2+1 which is 19 as a decimal.

 Example: Find the decimal equivalent of 101011. This as a
decimal is $1\times 2^{5}+1\times 2^{3}+1\times 2+1\times 1=32+8+2+1=43$ .

 Exercise: You might want
to try 11011 and show that its decimal equivalent is 27.


What does all this have to do with the magic trick? Take the number 19, as above, which is 10011 in binary. Remember that 10011 means $1\times 2^{4}+0\times 2^{3}+0\times 2^{2}+1\times 2^{1}+1\times 1=16+2+1.$ If we look at the cards with first numbers 16,2,and 1 we see that these three cards are the ones containing the number 19. That is, the number 19 has been placed on exactly those cards starting with the powers of 2 corresponding to a 1 in the binary expansion. (And so those numbers must sum to the number.)

In the same way the number 27, which is 101011 in binary, or $1\times 2^{5}+1\times 2^{3}+1\times 2+1\times 1=32+8+2+1,$ and you can check that it is on the cards starting with 1,2,8, and 32. The same holds for any other number between 1 and 63.

 Exercise: Show that 1110 represents the number 14 and that 14 is on the
cards beginning with 2, 4, and 8.


Finally, we might ask how the cards were created. To do this we need to be able to find the binary representation of a decimal number. This is easily shown with a couple of examples. Recall that the first few powers of 2 are 1, 2, 4, 8, 16, and 32.

Example: Write 38 in binary. Start by writing 38 as the sum of powers of 2. The highest
power of 2 that is less than 38 is 32, write 38=32+6. Since 6 is not a power
of two, we find the biggest power of 2 less than 6, which is 4, so we now have
38=32+4+2. Since 2 is a power of two we are done. Adding in all the skipped
powers of 2 gives, $38=1\times 32+0\times 16+0\times 8+1\times 4+1\times 2+0\times 1,$ or the
binary number 100110. We would place the number 38 on the cards with first
number 32, 4 and 2.

 Example: Write 15 in binary. Using the highest powers of two possible we find that 15=8+4+2+1,
which is 1111 in binary. We would place the number 15 on those cards with
first number 8,4,2, and 1.


## Using Binary to Create a Set of Cards

To make up a set of binary magic-cards we need to find the binary expansion of each number 1-63, and then place the numbers on those cards beginning with a power of two corresponding to a 1 in the binary expansion of the numbers. We will do a smaller example to show how this is done.

Example:
We will make up cards for the numbers 1-7. ( Seven is $2^{3}-1.$ Always choose
one less than a power of two for nice cards.) These cards are too small to be
interesting as a magic trick, but will show show the larger cards were created.We write each
card as a sum of powers of two:

1=1
2=2
3=2+1 (So 3 goes on the cards beginning with 2 and 1)
4=4
5= 4+1 (5 goes on cards beginning 4 and 1)
6 = 4+2 (6 goes on cards beginning 4 and 2)
7=4+2+1 (7 goes on cards beginning 4,2 and 1)

We see that we will only need three cards, one beginning with 1, one with
2, and one 4. Making up these cards and following the instructions above as to
where to put the other numbers we get the cards:

1 3 5 7

2 3 6 7

4 5 6 7


Thats all there is to it. We simply place each card where its binary expansions appear as the first numbers on the cards.

## Base-3 version

We can do the same thing in base-3, but with a twist. Here we use powers of 3:$1,3,3^{2}=9,3^{3}=27,\ldots$ for one set of cards (the A series); but we need a second set of cards for multiples of 2 times the powers of three (call those the B cards). We will make up cards for 1-8.

 1=1*1
2=2*1
3=    1*3
4=1*1+1*3
5=2*1+1*3
6=    2*3
7=1*1+2*3
8=2*1+2*3


Then we place the numbers on the cards that begin with a number in the number's sum. But before we do that we need to decide what to do with the number that appear twice. The easiest way to do this is to have two cards for each number. Then the number 5, containing two ones will be listed on both 'one' cards. The number 4 with just one will appear on only one of the one cards - we'll pick which one randomly, but try to balance the same number of numbers appearing on each card:

Card 1A:  1,4,7         Card 1B:  2,5,8
Card 3A:  3,4,5         Card 3B:  6,7,8



When play as usual by having the cards containing the chosen number handed to us. So if the number was 7, we would have cards 1A, and 3B. 1+2*3=7, so we have our answer! Or so we have Sheri's answer -- a fourth grader figured this out, with help from Don "The Mathman" Cohen 1930-2015 (thanks to Ralph D. Jeffords, for pointing Don -- and his kids -- out to me).

# The Fibonacci Card Trick

Since numbers can be written as a sum of non-consecutive Fibonacci numbers in only one way, we could also have a Fibonacci version of the cards. I am going to assume you are already familiar with the Fibonacci Numbers and have practiced writing each whole number as a sum of largest possible Fibonacci numbers. We make up cards for the numbers 1-12. (Why 12? Because 13 is a Fibonacci number, and we want one less than a Fibonacci number.)

 Fibonacci numbers less than 12:   1,2,3,5,8


We write each number less than 12 as a sum of these (using the largest possible:)

 1=1
2=2
3=3
4=3+1
5=5
6=5+1
7=5+2
8=8
9=8+1
10=8+2
11=8+3
12=8+3+1


Finally we place each number on the cards included in its sum:

 Card 1     1,4,6,9,12
Card 2     2,7,10
Card 3     3,4,11,12
Card 5     5,6,7
Card 8     8,9,10,11,12


We play as usual. If the chosen number were 11, then we would be told that it is on cards 3 and 8. Since 3+8=11, we know the chosen number.

Here are the ten cards you'll need for numbers up to 143 (143=F(12)-1):

 Card One 1 4 6 9 12 14 17 19 22 25 27 30 33 35 38 40 43 46 48 51 53 56 59 61 64 67 69 72 74 77 80 82 85 88 90 93 95 98 101 103 106 108 111 114 116 119 122 124 127 129 132 135 137 140 142 Card Two 2 7 10 15 20 23 28 31 36 41 44 49 54 57 62 65 70 75 78 83 86 91 96 99 104 109 112 117 120 125 130 133 138 143 Card Three 3 4 11 12 16 17 24 25 32 33 37 38 45 46 50 51 58 59 66 67 71 72 79 80 87 88 92 93 100 101 105 106 113 114 121 122 126 127 134 135 139 140 Card Four 5 6 7 18 19 20 26 27 28 39 40 41 52 53 54 60 61 62 73 74 75 81 82 83 94 95 96 107 108 109 115 116 117 128 129 130 141 142 143 Card Five 8 9 10 11 12 29 30 31 32 33 42 43 44 45 46 63 64 65 66 67 84 85 86 87 88 97 98 99 100 101 118 119 120 121 122 131 132 133 134 135 Card Six 13 14 15 16 17 18 19 20 47 48 49 50 51 52 53 54 68 69 70 71 72 73 74 75 102 103 104 105 106 107 108 109 136 137 138 139 140 141 142 143 Card Seven 21 22 23 24 25 26 27 28 29 30 31 32 33 76 77 78 79 80 81 82 83 84 85 86 87 88 110 111 112 113 114 115 116 117 118 119 120 121 122 Card Eight 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 Card Nine 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 Card Ten 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143

# The Prime Card Trick

Since numbers can be written as a products of prime numbers in only one way, we could also have a prime version of the cards. I am going to assume you are already familiar with the Prime Numbers and have practiced writing each whole number as a product of prime numbers.

One twist for primes is that we'll need cards for pure powers of all primes (in order to get a unique decomposition). Hence we'll need cards for powers of all primes such as 4, 8, 16, ...., 9, 27, 81, .... etc.

Prime cards to 100: (you'll see why this game isn't much played!;) So, for example, 84 is found on cards 4, 3, and 7, since the prime factorization is $84=2^{2}*3*7$ .

  2 6 10 14 18 22 26 30 34 38 42 46 50 54 58 62 66 70 74 78 82 86 90 94 98   3 6 12 15 21 24 30 33 39 42 48 51 57 60 66 69 75 78 84 87 93 96   4 12 20 28 36 44 52 60 68 76 84 92 100   5 10 15 20 30 35 40 45 55 60 65 70 80 85 90 95   7 14 21 28 35 42 56 63 70 77 84 91   8 24 40 56 72 88   9 18 36 45 63 72 90 99  11 22 33 44 55 66 77 88 99  13 26 39 52 65 78 91  16 48 80  17 34 51 68 85  19 38 57 76 95  23 46 69 92  25 50 75 100  27 54  29 58 87  31 62 93  32 96  37 74  41 82  43 86  47 94  49 98  53  59  61  64  67  71  73  79  81  83  89  97