def binaryForm(n, nbDigs=0):
    """Generates the bits of n in binary form.

    If the sequence has less than nbDigs digits, it is left-padded with zeros.
    """
    digits = []
    while n:
        digits.append(n & 1)
        n >>= 1
    return reversed(digits + [0]*(nbDigs - len(digits)))