What if an Infinite Number of Spaceships Arrive at Hilbert’s Hotel?

A Variation of the Classic Thought Experiment

An Infinite Hotel, generated by DALL-E, OpenAI.

Suppose you’ve just been hired as the new manager of Hilbert’s Infinite Hotel. 

On your first day you arrive at work only to be greeted by an infinitely long line of people in the lobby each expecting a room.

The Problem? All of the infinite number of rooms are already occupied by an infinite number of guests. The Infinite Hotel is full.

Turning them all away is out of the question — you’d get an infinite number of complaints and that would take literally forever to deal with.

You also can’t ask the current guests to leave to make room for the new ones as then you’d get an infinite number of 1 star reviews, and that would probably bring the average rating down a little.

To make matters worse, somehow this hotel with an infinite number of rooms only has 3 storage cupboards (!?) so you couldn’t even put the guests in there as you’d run out of space pretty quickly. (Plus, then where would you keep the infinite number of bedsheets?)

With your job on the line, the stakes have never been higher. How can you make space when there’s no space left? You decide it’s time to think outside the box.

Welcome to the paradox of the Infinite Hotel.

*Note: This thought experiment was originally posed by German Mathematician, David Hilbert. It has been adapted and retold many times since.


Let’s suppose all the rooms are numbered 1, 2, 3, …

If we asked every guest to move from their current room, n, to room n+1 then all of the guests still have a room, and room 1 becomes free. So the guest at the front of the queue will be able to take room 1. 

Unfortunately, there’s still an infinite number of guests left. If we repeat this process one room at a time, we will be here forever. By which time, another infinite number of guests will have arrived.

Instead, what if we ask everyone to move from room n to room 2n. The guest in room 1 goes to room 2, room 2 to room 4, room 3 to room 6, all the way to infinity. 

This will mean all of the even numbered rooms are occupied, and all of the odd numbered rooms are vacant. And of course, there is an infinite number of odd numbered rooms.

Perfect! we’re now able to allocate this infinite queue of guests to their own room.


But we’re not done yet.

Just when you think it’s all over, an infinite number of buses pull into the infinite carpark. There are of course, enough spaces for them. 

Each bus contains another infinite number of guests.

We need a new mathematical weapon to tackle this one… the Fundamental Theorem of Arithmetic!

The Fundamental Theorem of Arithmetic:

Every positive integer (except 1) can be expressed uniquely as a product of prime factors.

This means that there is only 1 way to represent the number 36 as a product of prime numbers:

36 = 2² * 3²

Even if we change the order (36 = 3² * 2² or even 36 = 3 * 2 * 3 * 2), the factors are still the same.


Luckily, each of the buses has a number on the front (1, 2, 3, …).

We first ask each of the existing guests to move from room n to room 2^n. For some guests, it may involve a lot of stairs, but in theory they will all end up with their own room again. And since it’s a power of 2, this new room will have an even room number.

Now that we’ve made some space, let’s tackle the coaches outside. 

We can ask each of the passengers to work out their coach number (i) and their seat number on that coach (j). We then instruct them all to do the following:

  • find the (i+1)th prime number, pᵢ ∈ {2, 3, 5, 7, 11, 13, 17, 19, … }
  • raise it to the power of j ∈ {1, 2, 3, 4, 5, … }

room number = pᵢ ʲ

For example, the passenger in coach 1, seat 2 takes the 2nd prime number, and raises it to the power of 2

3² = room 9

 The passenger behind them, in seat 3, will do something similar:

3³ = room 27

The next bus will do the same. Guests will be allocated room numbers:

5¹ = 5,

5² = 25.

5³ = 125, …

This will give all of the passengers a unique odd room number. How do we know it’s unique? The Fundamental Theorem of Arithmetic.

There’s only 1 way to represent the number 125 as a product of prime numbers, and that’s 5*5*5. There’s no other combination of bus number and seat number that will give us this value.

1 prime number per bus, and an infinite number of powers of those primes for the seat numbers.

 Problem Solved.


…but not for long.

Suddenly, an infinite number of spaceships materialise in the atmosphere (simultaneously of course). Each of them contains and infinite number of coaches. Each of those coaches contains an infinite number of new guests.

You may have noticed that after the previous reshuffle, there’s a lot of empty rooms throughout the hotel. Room 15 for example, will remain unoccupied since it cannot be expressed in the form pⁿ for some prime number, p.

15 = 5*3

What if we take the ship number, i, the bus number, j, and the seat number, k. We can then take the (i+1)th prime, pᵢ, and the (j+1)th prime, qⱼ, and take their product. Raising this to the power of k will give us:

ship 1, bus 2, seat 1: (3*5)¹ = room 15

ship 1, bus 2, seat 2: (3*5)² = room 225

This looks good so far, but there’s a slight problem:

ship 2, bus 1, seat 2: (5*3)² = room 225

We’ve double booked the room. In fact, we’ve accidentally double booked an infinite number of rooms!


Seeking a different approach, we instead try the following formula to work out a room number:

 room number = pᵢ ^ qⱼ ^ k = (i+1)th prime ^ (j+1)th prime ^ seat number

Again, for ship 1 (i), bus 2(j), seat 2(k), this becomes: 

 3 ^ 5 ^ 2 = room 847288609443

Let’s take a look at why this works:

Suppose that there are two passengers who are both allocated to the same room.

We’ll denote passenger 1’s ship number, bus number, and seat number as i₁, j₁ and k₁. 

This gives us the (i₁+1)th prime p₁, and the (j₁+1)th prime q₁. So passenger 1 will be assigned to room p₁ ^q₁ ^ k₁.

We can do the same for passenger 2 to give us the room number p₂ ^q₂ ^ k₂.

Again, we are assuming that they have been assigned to the same room, so these two numbers must be equal.

p₁ ^ (q₁ ^ k₁) = p₂ ^ (q₂ ^ k₂)

Using the Fundamental Theorem of Arithmetic, we must have that p₁ = p₂, and that (q₁ ^ k₁) = (q₂ ^ k₂) since q₁ ^ k₁ and q₂ ^ k₂ are just positive integers, and the prime factorisation must be unique.

We apply the theorem again to this new equation to tell us that q₁= q₂, and k₁ = k₂. 

Therefore, these two passengers are actually the same individual. Hence this equation will give us a unique room number for every passenger.


Suddenly, an infinite number of inter-dimensional portals open up around you. Through each, appears an infinite number of spaceships each with an infinite number of buses, with each of those having an infinite number of passengers.

You realise that you could just keep applying the Fundamental Theorem of arithmetic over and over again, however, you’re quite tired, and start to realise that you aren’t paid enough to have to deal with all of this. Instead you decide to quit and apply for a job at the infinite Café. How hard could that be?

Scroll to Top