def choose(n, r):
    """The number of ways of choosing r items from n
    All calculations done as integer.
    Parameters
    ----------
    n   number of items to choose from
    r   number of items to choose

    Returns
    -------
    combin  The number if ways of making the choice
    """
    if n < 0 or r < 0:
        print('Negative values not allowed')
        return 0
    if r > n:
        print('r must not be greater than n')
        return 0

    combin = 1
    r1 = min(r, n-r)
    for k in range(r1):
        combin = combin * (n - k) // (k + 1)

    return combin