Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Request for an equation

  1. Sep 19, 2004 #1
    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..


    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.
  2. jcsd
  3. Sep 19, 2004 #2


    User Avatar
    Science Advisor

    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.
  4. Sep 19, 2004 #3


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook