Hilbert's Hotel Paradox Calculator
Hilbert's Grand Hotel has infinitely many rooms, all occupied, yet it can always accommodate more guests. This calculator walks through three classic scenarios: a finite group arrives, a countably infinite crowd arrives, and infinitely many buses each carrying infinitely many passengers. Enter your numbers and see exactly which room each guest moves to, with step-by-step math.
What is Hilbert's Hotel Paradox?
Hilbert's Hotel (formally, Hilbert's paradox of the Grand Hotel) is a thought experiment devised by the German mathematician David Hilbert around 1924 to illustrate the counterintuitive properties of infinite sets. Imagine a hotel with infinitely many rooms, numbered 1, 2, 3, and so on without end, and suppose every room is already occupied. Intuitively it seems the hotel is full and cannot take another guest. But because the set of rooms is countably infinite, the manager can always rearrange existing guests to make room for newcomers, even infinitely many of them. The paradox does not involve any physical hotel; it is a demonstration that the arithmetic of infinite sets (transfinite arithmetic) behaves very differently from ordinary finite arithmetic.
The three core scenarios explained
Scenario 1 - Finite arrivals: k new guests arrive. The manager announces: 'Every guest, please move from your current room n to room n + k.' This shifts every guest up by k rooms, leaving rooms 1 through k vacant. Adding a finite number to a countably infinite set does not change its size. Scenario 2 - Infinite arrivals: A bus carrying infinitely many new guests pulls up. The manager moves each existing guest from room n to room 2n, filling all even-numbered rooms. Every odd room is now free, and the new arrivals fill them: the guest in seat s gets room 2s - 1. Both the even and odd natural numbers are themselves countably infinite, so both groups fit perfectly. This shows that aleph-null + aleph-null = aleph-null. Scenario 3 - Infinite buses, each with infinite passengers: Now infinitely many buses arrive, each with infinitely many passengers. The manager assigns each group its own prime number: existing guests use prime 2, bus 1 uses prime 3, bus 2 uses prime 5, bus 3 uses prime 7, and so on. Existing guest in room n moves to room 2^n; the passenger in seat s on bus b moves to room p_b^s, where p_b is bus b's prime. The Fundamental Theorem of Arithmetic guarantees that every natural number has a unique prime factorization, so no two guests can ever be assigned the same room. This proves that aleph-null times aleph-null = aleph-null.
Countable infinity and cardinality
The hotel scenarios are a concrete way to understand Georg Cantor's theory of cardinality. A set is called countably infinite (or countable) if its elements can be put into a one-to-one correspondence with the natural numbers 1, 2, 3, ... The set of natural numbers, even numbers, odd numbers, integers, and rational numbers are all countably infinite, all the same 'size' in the transfinite sense, denoted aleph-null. Hilbert's Hotel makes this vivid: moving guests around is exactly constructing such a bijection. By contrast, the real numbers between 0 and 1 are uncountably infinite (a larger infinity, aleph-one or the cardinality of the continuum), and they cannot be accommodated in the hotel by any rearrangement, which is what Cantor's diagonal argument proves. This distinction between countable and uncountable infinities is the foundation of modern set theory and underlies much of real analysis, topology, and theoretical computer science.
Why prime powers work and other methods
The prime-powers method used in Scenario 3 is elegant but not the only solution. Mathematicians have found at least four other approaches to the same problem. The interleaving (digit-interleaving) method alternates the digits of the bus number and seat number to produce a unique room: bus 12, seat 34 maps to room 1324. The triangular-number method assigns room T(b + s - 1) + s where T(k) = k(k+1)/2 is the k-th triangular number. The Cantor pairing function is a specific polynomial that bijects pairs of natural numbers onto the natural numbers: pair(b, s) = (b + s)(b + s + 1)/2 + s. All of these work because the set of all pairs of natural numbers is itself countably infinite, a fact that surprises most newcomers but follows directly from the diagonalization argument Cantor used. The prime-powers approach is favored in introductory explanations because the uniqueness guarantee (no two distinct sets of exponents give the same product) is immediately obvious to anyone who remembers prime factorization from school.
Hilbert's Hotel: Scenario Formulas at a Glance
| Scenario | Who moves | Formula | Key idea |
|---|---|---|---|
| 1 - Finite k guests | All existing guests | Room n + k | Shift everyone up by k |
| 2 - Infinite new guests | Existing guests | Room 2n (even) | Pack into even rooms |
| 2 - Infinite new guests | New arrivals (seat s) | Room 2s - 1 (odd) | Fill the odd rooms |
| 3 - Infinite buses | Existing guests | Room 2^n | Use powers of prime 2 |
| 3 - Infinite buses | Bus b, seat s | Room p_b^s | Each bus gets its own prime |
Summary of the three classic paradox scenarios and the mapping rules used.
Frequently asked questions
Is Hilbert's Hotel a real hotel?
No. It is a thought experiment, a mathematical abstraction invented to illustrate how infinite sets behave. No physical object can have infinitely many parts, but the logical structure of the argument is perfectly rigorous. The hotel is just a memorable way to talk about one-to-one correspondences between infinite sets.
How can a full hotel have room for more guests?
Because 'full' in the finite sense means 'every room is occupied.' But in an infinite hotel there is no last room, so there is always a room with a higher number. By shifting every guest to a higher room, we create vacancies at the lower end without anyone being displaced into the void. The total number of occupied rooms is still infinite; it has not grown or shrunk, which is the surprising property of countably infinite sets.
Why does the prime-powers method guarantee no conflicts?
The Fundamental Theorem of Arithmetic states that every integer greater than 1 has a unique factorization into prime numbers. Rooms assigned under the prime-powers scheme are of the form p^k for a specific prime p and a specific exponent k. Because the prime is different for each group (2 for existing guests, 3 for bus 1, 5 for bus 2, ...) and the exponent is different for each member within a group, no two guests can ever produce the same room number. Two different prime powers p^a and q^b are equal only if p = q and a = b, which never happens here since each group has its own prime.
Could an uncountably infinite crowd fill the hotel and leave no room for more?
Yes. If uncountably many guests arrived (the same size as the real numbers between 0 and 1), it is impossible to fit them all into a countably infinite hotel, no matter how clever the rearrangement. This is what Cantor's diagonal argument proves: you cannot build a one-to-one correspondence between the real numbers and the natural numbers. So even Hilbert's infinite hotel has a genuine capacity limit, just not a finite one.
What does this have to do with real mathematics?
Hilbert's Hotel is a gateway to set theory, the branch of mathematics that underpins almost all of modern math. The same ideas appear in the theory of cardinality (comparing sizes of infinite sets), in the proof that the rational numbers are countable, in the construction of the real numbers, and in computability theory (which programs can and cannot be written). Georg Cantor's discoveries about infinity in the 1870s-1890s were controversial at first but are now considered among the most important results in the history of mathematics.
What is aleph-null?
Aleph-null (written as the Hebrew letter aleph with a subscript zero) is the cardinality (size) of the set of natural numbers, and by extension of any countably infinite set. It is the smallest infinite cardinal number. The hotel scenarios show that aleph-null + k = aleph-null for any finite k, that aleph-null + aleph-null = aleph-null, and that aleph-null times aleph-null = aleph-null. The next infinity up is aleph-one, the cardinality of the real numbers, which cannot be put in correspondence with the natural numbers.
Can this calculator handle very large room numbers?
Yes for Scenarios 1 and 2, where room numbers grow linearly. For Scenario 3, room numbers grow exponentially: room 2^n for existing guests means that even guest 50 would be assigned to room 2^50, which is over a quadrillion. JavaScript handles integers exactly up to 2^53, so results are exact for reasonable inputs. The calculator will display the number, but physically fitting anyone there is, of course, left as an exercise for the reader.