I'm drawing a graph, and need to annotate the x axis. The x axis is dimensioned in days -- eg, 11/25, 11/26, 11/27... The number of of days on the x axis may range from about 10 to perhaps 100 or more, depending on circumstances. This is all displayed on a smartphone in portrait orientation, so the x axis is fairly short.
To annotate the x axis I'd like to draw "major tick marks" (short vertical lines) at intervals and label them with, eg, "11/26" (for today, Nov 26). There is room along the x axis, with a given font size, to fit in up to 7 date labels.
Between the "major tick marks" I'd like to insert multiple (though possibly zero) "minor tick marks". (These are even shorter vertical with no label.) Obviously, there should be an integral number of "minor tick marks" between the "major" ones, and each minor mark should denote some integral multiple of days. Along the axis there is room for about 50 "minor tick marks" before they start getting too crowded.
So how do I calculate, given a number of days to be covered, the greatest number of major and minor tick marks (ie, smallest space between) that will satisfy the criteria? Eg, when I applied the two criteria separately for one set of dates I came up with 13 days between major marks and 3 days between minor ones, and that doesn't really work. The closest reasonable numbers would appear to be 15 and 5, but how do I create an algorithm that arrives at that, without having to repeatedly calculate prime factors or some such?
(Note that absolute optimality (if that can even be defined) is not required here -- just a good, stable approximation that can be reliably implemented with simple (testable) code.)