
    Design a function that calculates the optimal connection distance for friend recommendations at a given network depth level n, where the connection threshold is determined by the nth number in a special sequence where each value is derived from its two predecessors using social graph properties. This sequence, starting with 1 and 1, generates numbers where each subsequent value equals twice the previous value minus the value before that, and only the prime numbers in this sequence are considered valid thresholds for friend recommendations.
    

    
def newman_prime(n):
    """
    Design a function that calculates the optimal connection distance for friend recommendations at a given network depth level n, where the connection threshold is determined by the nth number in a special sequence where each value is derived from its two predecessors using social graph properties. This sequence, starting with 1 and 1, generates numbers where each subsequent value equals twice the previous value minus the value before that, and only the prime numbers in this sequence are considered valid thresholds for friend recommendations.
    

    """
def newman_prime(n):
    """
    Design a function that calculates the optimal connection distance for friend recommendations at a given network depth level n, where the connection threshold is determined by the nth number in a special sequence where each value is derived from its two predecessors using social graph properties. This sequence, starting with 1 and 1, generates numbers where each subsequent value equals twice the previous value minus the value before that, and only the prime numbers in this sequence are considered valid thresholds for friend recommendations.
    

    """
    if n == 0 or n == 1:
        return 1
    return 2 * newman_prime(n - 1) + newman_prime(n - 2)