def all_factors(num):
    """ Return the set of factors of n (including 1 and n).
    You may assume n is a positive integer. Do this in one line for extra credit.

    Example:
    >>> all_factors(24)
    {1, 2, 3, 4, 6, 8, 12, 24}
    >>> all_factors(5)
    {1, 5}
    """

    factors = set()

    for i in range(1, int(num / 2) + 1):
        if num % i == 0:
            factors.add(i)
    factors.add(num)
    return factors