On Fri, Sep 16, 2011 at 2:40 AM, Chris Smith <[email protected]> wrote:

> instead of `a%p` write `a % p`. Also, since this will have to be
> computed again later you might as well do both at the same time:
>
> a, r = divmod(a, p)

if not r:
>    return 0
> if is_quad_residue(a, p):
>    return 1
> else:
>    return -1
>

for  a, p = 5, 11;  divmod(a, p) returns (0, 5) and we will be losing the
value of a if a < p and hence with little modification -

    _, r = divmod(a, p)
    if not r:
        return 0
    else:
        a = r
    if is_quad_residue(a, p):
        return 1
    else:
        return -1


>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>
>


-- 
-Regards
Hector

Whenever you think you can or you can't, in either way you are right.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to