def num_intra_memory_bonds(n_bp, memory_range, n_template):
    """Calculate the expected number of bonds for intra-strand associative memory force

    Args:
        n_bp (int): number of basepairs in the system
        memory_range (int): size of the memory
        n_template (int): number of templates used as memories

    Returns:
        int: number of expected intra-strand bonds
    """
    n_bonds = 0
    for i in range(1, memory_range):
        n_bonds += (n_bp - i) * (memory_range - i)
    n_bonds *= 2 * n_template
    return n_bonds