PDA

View Full Version : Request for an equation


Logic
Sep19-04, 01:38 PM
Let me start off by saying, I am terrible at math. I'm not even sure if I know how to explain this for you to understand, but here goes.

I am trying to obtain an equation for series of numbers, with a repeating pattern.


The numbers must be greater or equal to n.
The first series of numbers, must compose of n whole numbers after n.
After the first, and each series of numbers, n numbers must be excluded, followed by n series of numbers, and so on..


ex.

n = 4

would result in...

4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23....

n = 2

2, 3, 6, 7, 10, 11...

Thanks a lot in advance.

mathman
Sep19-04, 03:54 PM
m=(2j+1)*n+k, where j=0,1,2,.... and k=0,1,...,n-1. k goes through a complete cycle for each j.

Hurkyl
Sep19-04, 04:09 PM
Or if you're looking for an expression involving a single parameter, there are some tools you can use to build expressions.

floor(x / 4) is a function that repeats one integer four times, then the next integer four times, and so on.

x - 4*floor(x / 4) is a function that simply repeats the sequence 0, 1, 2, 3. (This computes the remainder of x divided by 4)


floor(X), here, is the greatest integer function. So, floor(4) = 4, floor(6.8) = 6, and floor(-2.3) = -3.


If you're writing this as a C program, and your parameter is always nonnegative then you can simply use (x / 4) for the first of these functions, and (x % 4) for the second.