Generate numbers by algorithm (interesting) : Maybe anyone know how to generate numbers in this way.

I have function, for example, `generate (current, count, limit)`

current – central number in array

count – max numbers count

limit - for example, 2 means two numbers before and after current number.


This function might return array like that:

    [ current - n, current - 1, current, current + 1, current + n ] (n < limit)

For example:

    generate(5, 10, 2)

Returns:

    [3, 4, 5, 6, 7]

But `generate(1, 5, 2)` must return `[4, 5, 1, 2, 3 ]`

Numbers before current take from reverse array of max numbers count.


