Search code examples
pythonalgorithmfunctionmathseries

What sort of Math series is this, what's the equation?


I'm not able to figure out what the actual formula or name for this series is:

3 : 5; 4 : 10 ; 5 : 15; etc..

Here is the code:

        i = 4
        n = 2
        while i <= granularity and i != 3:
            if (i == granularity):
                return 5 * n

            n += 1
            i += 1
        return 5

HERE IS MORE OF THE CODE I USED TO SOLVE THIS SERIES:

    def getChartData(self, sym, timescale="last_day", intraday="Y", granularity="3", ytdate="False", extdhrs="n"):
    dateMin = ""
    dateMax = ""
    alt = "hi" if timescale == "last_hi" else "lo" if timescale == "last_lo" else "cl" if timescale == "last_cl" else ""
    href = ""
    content = ""
    sorted_content = {}

    def granFac():
        gran = int(granularity)
        i = 4
        n = 2
        while i <= gran and i != 3:
            if (i == gran):
                return (dt.now() - td(minutes=(5 * n))).strftime("%Y/%m/%d-%H:%M:%S")

            n += 1
            i += 1
    
    return (dt.now() - td(minutes=5)).strftime("%Y/%m/%d-%H:%M:%S")

Solution

  • So the answer is most likely a combination of two suggestions. It turns out to be a function with a range that starts at 3 and increases by one, and a domain that has a set in multiples of five starting at 5.

    function { 3, 4, 5.. }( 5 | {} )
    -or-
    function { x ≥ 3, x ∈ Z+ }( {x|x ∈ Z+, x≡0 (mod 5)} )
    

    It seems there is a couple ways to write it depending on which crowd you come from.

    How I found the answer:

    Domain & Range

    Notating Multiples