My apologies if this is the wrong site for this problem, as it is more math-related than programming.
I am trying to write a series of 7 page links, in a Google-esque fashion. Essentially, it will be 7 numbers, s to (s + 6), where s is my starting value. I am having trouble calculating my starting value, given a limited amount of information.
In advance, I know the maximum value in the series, this is variable, but it is always greater than 7. In my formula-writing attempts, I have been calling this value g, so g > 7.
I also know the page number the user has selected. I have been calling this value p
So, for example, if g was 8, I would need to generate these series of numbers, where the bolded number is equal to p:
1 2 3 4 5 6 7
1 2 3 4 5 6 7
1 2 3 4 5 6 7
1 2 3 4 5 6 7
2 3 4 5 6 7 8
2 3 4 5 6 7 8
2 3 4 5 6 7 8
2 3 4 5 6 7 8
As long as I can determine the starting value using the information available, everything else falls into place. Can anyone advise on how I would calculate my starting value using the information available? If it is relevant, I will be writing this formula in PHP.
Thanks in advance for any input.
This is just simulation code for testing.
SO your Start Page is decided by (the thing you actually need):
Output (Simulation for g=16, and p from 1 to 16)::
p :: page numbers
And simulation for g=8, p from 1 to 8