Lucas numbers are numbers in a sequence defined like this:
```
L(0) = 2
L(1) = 1
L(n) = L(n-1) + L(n-2)
```

Your mission is to complete the function that returns the `n`th term of this sequence.

**Note:** It should work for negative numbers as well; how you do this is you flip the equation around, so for negative numbers: `L(n) = L(n+2) - L(n+1)`


## Examples
```
L(-10) = 123
L(-5)  = -11
L(-1)  =  -1
L(0)   =   2
L(1)   =   1
L(5)   =  11
L(10)  = 123
```

Difficulty: introductory

Starter code:

def lucasnum(n):
	

Solutions:
def lucasnum(n):
    a = 2
    b = 1

    flip = n < 0 and n % 2 != 0

    for _ in range(abs(n)):
        a, b = b, a + b
    
    return -a if flip else a

SEQUENCE = [2,  1]

def lucasnum(n):
    try:
        return SEQUENCE[abs(n)] * (1, -1)[n < 0 and n % 2]
    except IndexError:
        while len(SEQUENCE) < abs(n) + 1:
            SEQUENCE.append(SEQUENCE[-1] + SEQUENCE[-2])
        return lucasnum(n)

from numpy import matrix

def lucasnum(n):
    return int((matrix('2 1; 1 3') * matrix(
        '0 1; 1 1' if n >= 0 else '-1 1; 1 0', object
        ) ** abs(n))[0, 0])

memo = {0:2, 1:1}
current = [-1, 2]

def lucasnum(n):
    while n not in memo:
        if n < 0:
            x = current[0]
            memo[x] = memo[x+2] - memo[x+1]
            current[0] -= 1
        else:
            x = current[1]
            memo[x] = memo[x-2] + memo[x-1]
            current[1] += 1
    return memo[n]

def lucasnum(n):
    a, b = 2, 1
    for i in range(abs(n)):
        a, b = b, a + b
    return a * (-1 if n < 0 and n % 2 else 1)

memo = [2,1]

def lucasnum(n):
    m = abs(n)
    while len(memo) < m+1:
        memo.append(memo[-1]+memo[-2])
    return memo[m] * (-1)**(n<0 and n%2)

def lucasnum(n):
    a, b, i = 2, 1, 0
    while True:
        if i == n:    return a
        if n > 0:
            i += 1
            a, b = b, a+b
        else:
            i -= 1
            b,a = a, b-a   

def lucasnum(n):
    if n == 1:
        return 1
    elif n == 0:
        return 2
    elif n > 1:
        a, b = 2, 1
        for i in range(n):
            a, b = b, a+b
        return a
    else:
        a, b = -1, -2
        for i in range(abs(n)):
            a, b = b, a-b
        return b*-1

def lucasnum(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        if n > 1:
            a, b = 2, 1
            for i in range(n):
                a, b = b, a+b
            return a
        else:
            a, b = -1, -2
            for i in range(abs(n)):
                a, b = b, a-b
            return b*-1


lucas_sieve = [2, 1, 3, 4, 7]
def lucasnum(n):
  neg, n = 1 if n >= 0 or n % 2 == 0 else -1, abs(n)
  return neg * lucas_expand(n)
def lucas_expand(n):
  l = len(lucas_sieve)
  while n >= l:
    lucas_sieve.append(lucas_sieve[l - 1] + lucas_sieve[l - 2])
    l = len(lucas_sieve)
  return lucas_sieve[n]