# Bouncing screensaver

July 31, 2013 1:59 pm Leave your thoughtsWe’ve all seen the bouncing screensaver. And we’ve all watched, hoping it would fall into the corner. Oh, you haven’t? Well, watch this documentary footage of the adventure you’ve been missing.

The screensaver isn’t mysterious. It moves in predictable ways, meaning we can calculate how often it’ll hit the corner (and *if* it will hit a corner). So let’s start with some assumptions.

- The bouncing object is smaller than the screen.
- It starts in the upper left hand corner.
- It moves at a 45 degree angle.
- It bounces perfectly (i.e. it always is moving at a 45 degree angle).

From this, we can make a few quick observations. The total distance it has traveled left and right is always equal to the total distance it has traveled up and down. And in order to land in a corner, it must have traveled a whole multiple of the both the width and the height of the screen. Or to put it mathematically:

We can find the lowest possible values for both *m* and *n* (which must be integers) fairly easily. The definition of the greatest common divisor of W and H implies that:

You can follow the same logic to calculate the value of m.

So now we know how many times the bouncing object travels the width of the screen (m) and the height of the screen (n). Each of those traversals will be followed by a bounce. We’ll need to subtract 1, because the last bounce — the impossible dream, the bounce in the corner — is counted as a horizontal *and* a vertical bounce. So the number of bounces necessary is:

Let’s find out how many times Jim and Pam and the others would have to watch the screen saver bounce to see it go into a corner. The DVD was most likely running at an effective resolution of 640×480 (equivalent to 480p). It’s hard to tell the size of the bouncing object, but it’s definitely smaller than a quarter of the height, plus it appears to have an non-bouncing border. Let’s eyeball it at 50×50. So:

Left as an exercise for the reader: Which corner will the object bounce in? Is it possible for the object to *only* bounce in the upper-left hand corner (where it starts)?