def iter_algorithm(d, n, p, corpus, pr):
    """
    PR(p) = ( (1-d) / n ) + ( d * sum( PR(i) / NumLinks(i) ) )
                                   i
    d = dampening number; n = # of possible pages; p = page; i = incoming pages                                  
    """
    page_sum = 0
    # This for loop will calculate the sum portion of the equation
    for i in corpus:
        # Find all incoming pages. p = pg and i = i
        if p in corpus[i]:
            # Update the sum to include each instance for the probablity of page i divided by NumLinks on page i
            page_sum += pr[i] / len(corpus[i])

    # Insert sum into rest of iterative algorithm
    return ((1 - d) / n) + (d * page_sum)