ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 28 Apr 2019 17:34:13 -0500How would I be able to check if a given number is a solinas prime?https://ask.sagemath.org/question/46327/how-would-i-be-able-to-check-if-a-given-number-is-a-solinas-prime/Using sage, how would I be able to check whether a given number is a general mersenne prime, or if possible any other special primes?
In particular, looking to check for special primes `p` such that modulo `p` is easy to calculateWed, 24 Apr 2019 01:36:50 -0500https://ask.sagemath.org/question/46327/how-would-i-be-able-to-check-if-a-given-number-is-a-solinas-prime/Comment by vdelecroix for <p>Using sage, how would I be able to check whether a given number is a general mersenne prime, or if possible any other special primes?</p>
<p>In particular, looking to check for special primes <code>p</code> such that modulo <code>p</code> is easy to calculate</p>
https://ask.sagemath.org/question/46327/how-would-i-be-able-to-check-if-a-given-number-is-a-solinas-prime/?comment=46382#post-id-46382Regarding your question
- what is a "special prime"?
- what do you mean by "modulo p is easy to calculate"?Sat, 27 Apr 2019 15:38:49 -0500https://ask.sagemath.org/question/46327/how-would-i-be-able-to-check-if-a-given-number-is-a-solinas-prime/?comment=46382#post-id-46382Answer by slelievre for <p>Using sage, how would I be able to check whether a given number is a general mersenne prime, or if possible any other special primes?</p>
<p>In particular, looking to check for special primes <code>p</code> such that modulo <code>p</code> is easy to calculate</p>
https://ask.sagemath.org/question/46327/how-would-i-be-able-to-check-if-a-given-number-is-a-solinas-prime/?answer=46397#post-id-46397
The ["Solinas prime" wikipedia page](https://en.wikipedia.org/wiki/Solinas_prime) says
a Solinas prime is a prime of the form `f(2^m)` where `f` is a polynomial of low degree,
and gives a few examples.
Hint: observe the structure of bits of each of these primes:
sage: l = [
....: 2^192 - 2^64 - 1,
....: 2^224 - 2^96 + 1,
....: 2^256 - 2^224 + 2^192 + 2^96 - 1,
....: 2^384 - 2^128 - 2^96 + 2^32 - 1,
....: 2^448 - 2^224 - 1
....: ]
sage: for p in l:
....: print(p.bits())
Then define a function to detect `m` and the polynomial from the bit structure.
Sun, 28 Apr 2019 17:34:13 -0500https://ask.sagemath.org/question/46327/how-would-i-be-able-to-check-if-a-given-number-is-a-solinas-prime/?answer=46397#post-id-46397