def sum_range(n, total=0):
    """Sum the integers from 1 to n.

    Obviously the same as n(n+1)/2, but this is a test, not a demo.

    >>> sum_range(1)
    1
    >>> sum_range(100)
    5050
    >>> sum_range(100000)
    5000050000L
    """
    if not n:
        return total
    else:
        raise TailCall(sum_range, n - 1, n + total)
Sum the integers from 1 to n.

    Obviously the same as n(n+1)/2, but this is a test, not a demo.

    >>> sum_range(1)
    1
    >>> sum_range(100)
    5050
    >>> sum_range(100000)
    5000050000L
    
recipes/Python/534104_Explicit_Tail_Call/recipe-534104.py