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

Help determining an equation that describes a pattern

  1. Oct 7, 2009 #1
    Hi all,

    Been a looooong time since I had to use calculus for anything, but I distinctly remember failing this section of the course miserably. I can describe a pattern but for the life of me I can't write an equation that describes the pattern I see.

    For a program I'm wrtting for work I need to write an equation that will describe the following pattern:

    If n = 1 to 93 then x = 1
    (diff = 92)
    If n = 94 to 183 then x = 2
    (diff = 89)
    If n = 184 to 276 then x = 3
    (diff = 92)
    If n = 277 to 366 then x = 4
    (diff = 89)
    and so on and so forth...

    ANy help would be greatly appriciated. I know it's possible to write a sigma equation to describe this sort of pattern, but like I said I failed this section of my calculus course miserably! Never thought I'd actually use it again!

    --Ouka
     
  2. jcsd
  3. Oct 7, 2009 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Is there some reason you need to actually create an equation to describe this? Since you're writing a computer program, why can't you do something like this?

    Code (Text):

    def f(n):
        acc = 0
        i = 0
        x = 0
        while (acc < n):
            if (i == 0):
                acc = acc + 93
            else:
                acc = acc + 90
           
            i = (i + 1) % 2
            x = x + 1
           
        return x
     
    - Warren
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Help determining an equation that describes a pattern
Loading...