From a given natural integer, returns the list of divisors in ascending order
    :param n: Natural integer
    :return: List of divisors of n in ascending order
184598
def divisors(n):
    
    factors = _factor_generator(n)
    _divisors = []
    listexponents = [[k**x for x in range(0, factors[k]+1)] for k in list(factors.keys())]
    listfactors = _cartesian_product(listexponents)
    for f in listfactors:
        _divisors.append(reduce(lambda x, y: x*y, f, 1))
    _divisors.sort()
    return _divisors
953618
def factorial(n):
    
    f = 1
    while (n > 0):
        f = f * n
        n = n - 1
    return f
330282
def get_keys_of_max_n(dict_obj, n):
    
    return sorted([
        item[0]
        for item in sorted(
            dict_obj.items(), key=lambda item: item[1], reverse=True
        )[:n]
    ])
224696
public List<T> last(final int n) {
        N.checkArgument(n >= 0, "'n' can't be negative: " + n);

        if (N.isNullOrEmpty(coll) || n == 0) {
            return new ArrayList<>();
        } else if (coll.size() <= n) {
            return new ArrayList<>(coll);
        } else if (coll instanceof List) {
            return new ArrayList<>(((List<T>) coll).subList(coll.size() - n, coll.size()));
        } else {
            final List<T> result = new ArrayList<>(N.min(n, coll.size()));
            final Iterator<T> iter = coll.iterator();
            int offset = coll.size() - n;

            while (offset-- > 0) {
                iter.next();
            }

            while (iter.hasNext()) {
                result.add(iter.next());
            }

            return result;
        }
    }
894523
def get_factors(n):
    

    def factor(n, i, combi, res):
        """[summary]
        helper function

        Arguments:
            n {[int]} -- [number]
            i {[int]} -- [to tested divisor]
            combi {[list]} -- [catch divisors]
            res {[list]} -- [all factors of the number n]
        
        Returns:
            [list] -- [res]
        """

        while i * i <= n:
            if n % i == 0:
                res += combi + [i, int(n/i)],
                factor(n/i, i, combi+[i], res)
            i += 1
        return res
    return factor(n, 2, [], [])
1292452
def floats(self, n: int = 2) -> List[float]:
        
        nums = [self.random.random()
                for _ in range(10 ** int(n))]
        return nums
351094
def take(self, n):
        
        if n <= 0:
            return self._transform(transformations.take_t(0))
        else:
            return self._transform(transformations.take_t(n))
352638
def get_path(num):
        
        num = int(num)
        dig_len = len(str(num))
        paths = []
        for i in range(dig_len - 2):
            divisor = 10 ** (dig_len - i - 1)
            paths.append(
                "{}-{}".format((num // divisor) * divisor, (((num // divisor) + 1) * divisor) - 1)
            )
        return "/".join(paths)
229982
def divisors(n):
  """"""
  for i in range(1, int(math.sqrt(n) + 1)):
    if n % i == 0:
      yield i
      if i*i != n:
        yield n / i
544373
def exactly_n(l, n=1):
    '''
    
    '''
    i = iter(l)
    return all(any(i) for j in range(n)) and not any(i)
1058519
def get_unf(N=100):
    
#
# get uniform directions  [dec,inc]
    z = random.uniform(-1., 1., size=N)
    t = random.uniform(0., 360., size=N)  # decs
    i = np.arcsin(z) * 180. / np.pi  # incs
    return np.array([t, i]).transpose()

# def get_unf(N): #Jeff's way
    """
     subroutine to retrieve N uniformly distributed directions
    """
1344084
public List<T> first(final int n) {
        N.checkArgument(n >= 0, "'n' can't be negative: " + n);

        if (N.isNullOrEmpty(coll) || n == 0) {
            return new ArrayList<>();
        } else if (coll.size() <= n) {
            return new ArrayList<>(coll);
        } else if (coll instanceof List) {
            return new ArrayList<>(((List<T>) coll).subList(0, n));
        } else {
            final List<T> result = new ArrayList<>(N.min(n, coll.size()));
            int cnt = 0;

            for (T e : coll) {
                result.add(e);

                if (++cnt == n) {
                    break;
                }
            }

            return result;
        }
    }
48229
def example(n):
    
    J,p,r,d,w = multidict({
        1:[1,4,0,3],
        2:[4,0,0,1],
        3:[2,2,0,2],
        4:[3,4,0,3],
        5:[1,1,0,1],
        6:[4,5,0,2],
        })
    return J,p,r,d,w
982022
def non_decreasing_series(n, size):
    ''''''

    if size == 1:
        return [[a] for a in range(n)]
    else:
        lc = non_decreasing_series(n, size-1)
        ll = []
        for l in lc:
            last = l[-1]
            for i in range(last, n):
                e = l + [i]
                ll.append(e)
        return ll
407693
def natural_sort(list, key=lambda s:s):
    
    def get_alphanum_key_func(key):
        convert = lambda text: int(text) if text.isdigit() else text
        return lambda s: [convert(c) for c in re.split('([0-9]+)', key(s))]
    sort_key = get_alphanum_key_func(key)
    list.sort(key=sort_key)
341225
def ncr(n, r):
    
    r = min(r, n - r)
    numer = reduce(op.mul, range(n, n - r, -1), 1)
    denom = reduce(op.mul, range(1, r + 1), 1)
    return numer // denom
1298646
def array(self,n=-1):
        
        if n is None:
            return np.array(self.list)
        return np.array(self.list)[n]