How can the US national flag canton be patterned for a given number of stars? Of course we know that both legally and aesthetically you can chose whichever pattern you like, but usually this question expects an answer restricted to the regular patterns of ordered rows as in official use since 1912.
There are four different resulting patterns. For any given final number of stars (and considering only vexillographically realistic parameters - e.g. not things like one row of 51 stars should PR, or DC, or LI, or WE become a state), either several of these four patterns can be used, or only one, or even none. These four patterns are:
The plain pattern (q⃰), made of a number of rows with identical number of stars each - usually these show in a rank-and-file arrangement, as in the famous 48-star flag (1912-1959), with six rows with eight stars on each. To make room for bigger stars, however, each other row may be shifted sideways, resulting in a zigzag pattern (and making the whole pattern to look "pointy" and "rounded" at opposite corners) without changing anything about the numbers; such is the case of the official version of the 49-star flag (1959-1960), with seven zigzag rows of seven stars each.
The staggered pattern with even rows (e⃰), made of an even number of rows in which every other row has one star less than (or more) the previous row (the whole will look either "pointy" above and "rounded" at the bottom, or the opposite - numbers don't change); such is the 45-star flag (1896-1908) we show at with six rows and eight stars on the top row.
The staggered pattern with odd rows and "pointy" corners (p⃰), made of an odd number of rows in which every other row has one star less than the previous row and the top row have one star more than the second row (or the bottom row has one star more than the next-to-last row), as in the current flag, with nine rows and six stars on the top one. U.S. flag (1960-): p⃰(6;5) = 50 stars
The staggered pattern with odd rows and "round" corners (r⃰), made of an odd number of rows in which every other row has one star more than the previous row and the top row have one star less than the second row (or the bottom row has one star less than the next-to-last row), as in the 13-star John Shaw flag, with three rows and four stars on the top one.
To put these into formulae that will crunch our data and spit out results, lets consider two numbers, which we'll call w and h: The number of stars in the longer rows (1st or 2nd row, depending if the pattern is "pointy" or "rounded") is w, while h is the number of longer rows (that's the number of rows for the simple rank-and-file pattern).
The given examples can be expressed thus:
Official 1912-1959 flag <us-1912.html>: q⃰ˢ(8;6) = 48 stars
Official 1959-1960 flag <us-1959.html>: q⃰ᶻ(7;7) = 49 stars
Reported 1896-1908 flag <us-1896.html>: e⃰(8;3) = 45 stars
John Shaw flag (1776) <us-shaw.html>: r⃰(5;1) = 13 stars
The formulae for each of these functions follows: q⃰(w;h) = wh e⃰(w;h) = wh+h(w-1)
p⃰(w;h) = wh+(w-1)(h-1) r⃰(w;h) = wh+(w-1)(h+1)
Note that I used above q⃰ˢ and q⃰ᶻ to add to the star and row count also a description of the pattern arrangement (simple and zigzag), but they share the same algebraic definition - simple multiplication.
Note also that I refer to rows and not to columns because the US flag has a horizontally oblong canton - should you need to
describe a vertical flag in the same terms, just swap w and h around.
As for the answer to our question - how to design the canton of a flag with 51, 53, 58, 69 and whatever number of stars? (a prominent matter in many science fiction settings...) - it is simple to come up with a list of numbers, by just iterating the formulae above for integers. However, as said, some arrangements would not fit a sensible design for an U.S. flag, and I tried to weed them out: I limited the iterations to values of w between h and 5h (which still allows for really too oblong arrangements for higher values...) and listed only totals up to 200 stars, allowing for really aggressive Manifest Destiny scenarios and/or Balkanization within the current borders.