I am trying to develop an algorithm which involves the selection of an immediate minimum and maximum limit when an input is provided.
For instance I have a list of numbers which increment equally;
-20, -16, -12, -8, -4, 0, 4, 8, 12, 16, 20
If this algorithm recieves an input of 3, then as I know the set of numbers increment equally in 4 then the minimum and maximum to extract is 0 and 4 respectively. If the input is -13 then the minimum and maximum is -16 and -12 respectively.
Is there an algorithm already out there that implements, if not can someone guide to an eficient way of developing this?
Thanking you in advance.