posted 3 weeks ago
The double-sided printing sequence is just (back--), (front++), (front++), (back--) until back <= front
That is, assuming you have a multiple of 4 pages (and if not, you need to add empty pages to make it so) and page numbers go from 1..N where N is a multiple of 4, the sequence is N, 1, 2, N-1, N-2, 3, 4, N-3, N-4, 5, 6, N-5, N-6, 7, 8, N-7, N-8, 9, 10, ...
For single-sided printing, you just divide the sequence into pairs and use every other pair to print the first side, turn that pile over and use all the other pairs to print the second side.