def scale_factor(redshift):
    """
    Calculates the scale factor, a, at a given redshift.

    a = (1 + z)**-1

    Parameters
    ----------
    redshift: array-like
        The redshift values.

    Returns
    -------
    a: array-like
        The scale factor at the given redshift.

    Examples
    --------
    >>> scale_factor(1)
    0.5

    >>> scale_factor(np.array([0, 1, 2, 3]))
    array([1, 0.5, 0.3333333, 0.25])

    """

    a = (1 + redshift)**-1.0
    return a