Number Guessing Magic Trick
✨ The Fibonacci Magic Trick & Zeckendorf's Theorem
This magic trick relies on a fascinating mathematical principle involving Fibonacci numbers and a unique decomposition known as Zeckendorf's Theorem. By having someone select rows from a specially constructed list, the "magician" can deduce their chosen number by summing the first Fibonacci number in each selected row.
🎲 The Magic Trick Explained
The trick involves a list of numbers organized into rows, where the first number of each row is a Fibonacci number.
Audience selects a number: The person thinks of a number between 1 and 100.
Identify relevant rows: The person then indicates every row where their chosen number appears.
Magician reveals the number: The magician sums the first number of each selected row, and this sum reveals the audience's secret number.
Example: If the chosen number was 72, the magician would have selected rows starting with 1, 3, 13, and 55. Summing these: 1+3+13+55=72. This method always works.
🔢 Understanding Fibonacci Numbers
The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, starting from 1 and 1 (or 0 and 1).
The sequence begins: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Mathematically, it's defined as Fn=Fn−1+Fn−2, with F1=1 and F2=1.
For instance, to get the next number after 5 and 8, you add them: 5+8=13.
📜 Zeckendorf's Decomposition & Base Fibonacci
The core of the trick lies in Zeckendorf's Theorem, which states that every positive integer can be uniquely represented as a sum of non-consecutive Fibonacci numbers. This is called the Zeckendorf decomposition.
🌟 Key Properties of Zeckendorf's Decomposition:
Uniqueness: Every positive integer has only one Zeckendorf decomposition.
Non-adjacency: No two Fibonacci numbers in the sum are adjacent in the Fibonacci sequence.
For example, if a decomposition includes 8, it cannot also include 5 or 13.
Example: Decomposing 27
Valid Zeckendorf Decomposition: 27=21+5+1
Here, 21, 5, and 1 are all Fibonacci numbers, and none are adjacent in the sequence (e.g., 21 is not next to 5, 5 is not next to 1).
Invalid (non-unique) Decompositions:
27=13+8+5+1 (13 and 8 are adjacent)
27=21+3+2+1 (3 and 2 are adjacent)
📊 Base Fibonacci Representation
Just like numbers can be represented in binary (base 2) or decimal (base 10), they can also be represented in Base Fibonacci. This representation uses a sequence of 0s and 1s corresponding to Fibonacci numbers, where a '1' indicates the presence of that Fibonacci number in the Zeckendorf decomposition.
Let's use the Fibonacci sequence (excluding the first 1 for simplicity here, often F1=1,F2=2,F3=3 in this context): ... 89, 55, 34, 21, 13, 8, 5, 3, 2, 1
For 27:
Its Zeckendorf decomposition is 21+5+1.
In Base Fibonacci, this would be:
21 (yes) → 1
13 (no) → 0
8 (no) → 0
5 (yes) → 1
3 (no) → 0
2 (no) → 0
1 (yes) → 1
So, 27 in Base Fibonacci is 1001001.
💡 The Greedy Algorithm
The greedy algorithm is used to find the unique Zeckendorf decomposition for any number. It naturally ensures that no two adjacent Fibonacci numbers are selected.
Steps of the Greedy Algorithm:
Start with the largest Fibonacci number: Given a target number, find the largest Fibonacci number that is less than or equal to it.
Subtract and repeat: Subtract this Fibonacci number from the target number.
Continue with the remainder: Repeat the process with the remainder, always selecting the largest possible Fibonacci number that is less than or equal to the current remainder and not adjacent to the previously chosen Fibonacci number.
Example: Decomposing 100
Largest Fibonacci number ≤100 is 89.
Remainder: 100−89=11.
Next, largest Fibonacci number ≤11 (and not adjacent to 89) is 8.
Remainder: 11−8=3.
Next, largest Fibonacci number ≤3 (and not adjacent to 8) is 3.
Remainder: 3−3=0.
So, the Zeckendorf decomposition of 100 is 89+8+3. Notice that 89, 8, and 3 are non-adjacent Fibonacci numbers.
🚫 Why the Greedy Algorithm Prevents Adjacent Numbers
If the greedy algorithm ever picked two adjacent Fibonacci numbers, say Fn and Fn−1, it would contradict the "greedy" choice. This is because Fn+Fn−1=Fn+1 (by definition of Fibonacci numbers).
If you picked Fn and then Fn−1, it means that Fn+1 must have been larger than the current remaining amount when you first chose Fn.
However, if Fn+1 was available and smaller than or equal to the initial amount, the greedy algorithm would have picked Fn+1 first, not Fn.
Therefore, it's impossible to pick two adjacent Fibonacci numbers using the greedy algorithm, ensuring the uniqueness and non-adjacency of the Zeckendorf decomposition.
📝 How the Lists are Created for the Trick
The magic list is constructed directly from the Zeckendorf decomposition.
Each row is associated with a specific Fibonacci number (the first number in that row).
A number appears in a given row if and only if that row's associated Fibonacci number is part of the number's Zeckendorf decomposition.
Example: Number 27
Zeckendorf decomposition of 27 is 21+5+1.
Therefore, 27 will appear in the row starting with 1, the row starting with 5, and the row starting with 21.
It will not appear in rows starting with 2, 3, 8, 13, 34, 55, etc., because those Fibonacci numbers are not part of its unique non-adjacent sum.
When the audience selects all rows containing their number, they are essentially identifying the Fibonacci numbers that make up their number's Zeckendorf decomposition. By summing the first number of each selected row, the magician effectively sums these Fibonacci components, revealing the original number. This is the mathematical magic behind the trick!

Ask anything
We've read this whole study set, so questions about it get the best answers.