A mathematician figures out the best way to jam an extra star onto the American flag. Plus: Generate patterns for every possible flag up to 100 stars.

Three weeks ago, a Senate committee heard testimony on a bill that could bring Puerto Rico a step closer to becoming the 51st state. The Puerto Rico Democracy Act of 2010, which passed the House in late April, would grant the territory’s residents a vote on the island’s political status, with options including statehood or independence. If Puerto Rico were to become the 51st state—and granted, that’s at least four ifs away—federal law requires that a new star be added to the American flag. One can’t help but wonder: Where would we put it?

I put the question to mathematician Skip Garibaldi, who did what anyone would do in this situation: He wrote a computer program to figure out all possible combinations for flags of any number of stars. To do this, he looked at all the flags we’ve flown throughout American history, found the most common patterns, and figured out which of those patterns worked for a given number of stars. Garibaldi kindly sent me his code, which I used to make this interactive flag calculator based on the six most common star configurations:

As you’ll see, 51 stars arrange themselves quite nicely into six alternating rows of nine and eight. I’ve termed this the “alternate” pattern, since the flag alternates rows with an odd number of stars and rows with an even number of stars. A 51-star flag also works as a “Wyoming” pattern—an adaptation of the 44-star design used after the Cowboy State’s admission to the union in 1890. Going by the Wyoming style, our 51-star flag would have five rows of seven stars each sandwiched by a pair of eight-star rows at the top and bottom. Feel free to informally vote for which 51-star pattern looks better by leaving a comment.

Generally speaking, most star-spangled banners arrange the stars in ways that are vertically symmetrical, horizontally symmetrical, or both. Vertical symmetry means the left half of the blue square is a mirror image of the right. In a horizontally symmetrical flag, the bottom half of the blue square is a mirror image of the top half. The 23-star flag has vertical symmetry but not horizontal, while the 15-star flag has horizontal symmetry but not vertical. Many patterns, like the 50-star flag, have both.

There is also the issue of whether a pattern fits neatly into a squarish shape. While 51 stars would technically arrange into three rows of 17 stars, one has difficulty imagining this on a flag. Generally speaking, most configurations align every row of stars with the gaps of the previous row, making the stars less cramped. (Our current flag is a good example.) To make this work, half of the rows must have one fewer star than the rows above and below. (In the case of the 50-star flag, the rows alternate between six and five stars.) For numbers that conveniently arrange into rectangles—like six rows of eight for 48 stars—a simple matrix suffices.

With those rules in mind, the six flag patterns Garibaldi uncovered can be defined as follows:

Long: Alternating rows of even and odd numbers of stars, beginning and ending with the longer row. This is the pattern of our current 50-star flag.

Short: Like the previous pattern, but beginning and ending on the shorter row. This pattern has never been used on the American flag. Out of our six patterns, however, it’s the only one that’s viable for a hypothetical 71-star flag.

Alternate: Like the long and short patterns, but with the same number of odd and even rows, as in the 45-star flag.

Equal: Every row has the same number of stars, like the 30-star or 48-star flag.

Wyoming: The first and last rows have one more star than the interior rows. In addition to the 1890 flag, issued after Wyoming became a state, the 26-star, 32-star, and 37-star flags looked like this.

Oregon: The middle row has two fewer stars than all the other rows, as in the 33-star flag issued upon Oregon’s statehood. This only works for flags with an odd number of rows.

You can use the widget above to design hypothetical flags of up to 100 stars. The 29-, 69- and 87-star flags are the only ones that cannot be shoehorned into one of these patterns.

Think you’ve found a pattern for any of these three hypothetical Americas? E-mail me and maybe we’ll add your pattern to the widget. In the meantime, it’s best to hope the United States doesn’t grant statehood to Puerto Rico and all 18 governorates of Iraq.