(p)
return (b, a % b)
Represent a prime `p` which is congruent to 1 mod 4, as a sum of two
    squares.

    Examples
    ========

    >>> from sympy.solvers.diophantine import prime_as_sum_of_two_squares
    >>> prime_as_sum_of_two_squares(5)
    (2, 1)

    Reference
    =========

    .. [1] Representing a number as a sum of four squares, [online],
        Available: http://www.schorn.ch/howto.html
Represent a prime `p` which is congruent to 1 mod 4, as a sum of two
    squares.
Represent a prime p which is congruent to 1 mod 4 as a sum of two squares .
def prime_as_sum_of_two_squares(p):
    """
    Represent a prime `p` which is congruent to 1 mod 4, as a sum of two
    squares.

    Examples
    ========

    >>> from sympy.solvers.diophantine import prime_as_sum_of_two_squares
    >>> prime_as_sum_of_two_squares(5)
    (2, 1)

    Reference
    =========

    .. [1] Representing a number as a sum of four squares, [online],
        Available: http://www.schorn.ch/howto.html
    """
    if p % 8 == 5:
        b = 2
    else:
        b = 3

        while pow(b, (p - 1) // 2, p) == 1:
            b = nextprime(b)

    b = pow(b, (p - 1) // 4, p)
    a = p

    while b**2 > p:
        a, b = b, a % b

    return (b, a % b)
def prime_as_sum_of_two_squares ( p ) : if p % 8 == 5 : b = 2 else : b = 3 while pow ( b , ( p - 1 ) // 2 , p ) == 1 : b = nextprime ( b ) b = pow ( b , ( p - 1 ) // 4 , p ) a = p while b ** 2 > p : a , b = b , a % b return ( b , a % b )