On Jul 24, 1:24 pm, raman <[email protected]> wrote:
> Hi Dears
> First I  must find all primes in the form p=8k+1 or p=8k+7 in range
> 10000.

 [p for p in prime_range(10^4) if p%8 in [1,7]]


> Second I should find the all integers a and b such that p=a^2-2b^2 in
> range 10000.

[list(K.ideal(p).factor()[0][0].gens_reduced()[0]) for p in
prime_range(10^4) if p%8 in [1,7]]

Explanation:  the solution a,b is unique up to signs and a+b*sqrt(2)
is one of the prime factors in the rank Z[sqrt(2)].

I make no pretence that that either of the above is the most efficient
way of solving these!

John Cremona

> Could you please help me for writing this  program?

-- 
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/sage-support
URL: http://www.sagemath.org

Reply via email to