Create a function that takes a number and finds the factors of it, listing them in **descending** order in an **array**.

If the parameter is not an integer or less than 1, return `-1`. In C# return an empty array.

For Example:
`factors(54)` should return `[54, 27, 18, 9, 6, 3, 2, 1]`

Difficulty: introductory

Starter code:

def factors(x):
	

Solutions:
def factors(x):
    if not isinstance(x, int) or x < 1:
        return -1
    return [i for i in range(x, 0, -1) if x % i == 0]


def factors(x):
    if not isinstance(x, int) or x < 1:
        return -1
    return sorted({j for i in range(1, int(x**0.5)+1) if x % i == 0 for j in [i, x//i]}, reverse=True)


def factors(x):
    if type(x) == str or x < 1 or type(x) == float:
        return -1

    else:
        divisor = list(range(1,x+1))
        ans = []
        for i in divisor:
            if x % i == 0:
                ans.append(i)
                ans.sort(reverse = True)
        return ans


factors=lambda n:-1if not n or type(n)!=int or n<1else[e for e in range(n,0,-1)if n%e==0]

def factors(x):
    return -1 if type(x) != int or x < 1 else \
          [ n for n in range(x, 0, -1) if x % n == 0 ]

def factors(n):
  from math import sqrt
  
  if not isinstance(n, int) or n < 1:
    return -1

  lim = int(sqrt(n))
  divisors = set([n, 1])
  
  start = 2 + n%2
  step = start - 1
  
  for i in range(start, lim+1, step):
    if n%i == 0:
      divisors.add(i)
      divisors.add(n//i)
  
  return sorted(divisors, reverse=True)

def factors(x):
    return [i for i in range(x, 0, -1) if not x % i] if isinstance(x, int) and x > 0 else -1