Given that (n+p)=n2 mod p, you just have to compute the numbers n2modp for all integers between 0 and p−1. If you want to avoid repetitions, you just have to put them in a set. Here is how:
sage: p = 17
sage: S = {n^2 % p for n in range(p)}
sage: S
{0, 1, 2, 4, 8, 9, 13, 15, 16}
sage: p = 123457
sage: S = {n^2 % p for n in range(p)}
sage: len(S)
61729
![]() | 2 | No.2 Revision |
Given that (n+p)=n2 mod p, you just have to compute the numbers $n^2 { \mbox{ mod } pforallintegersbetween0andp-1$. If you want to avoid repetitions, you just have to put them in a set. Here is how:
sage: p = 17
sage: S = {n^2 % p for n in range(p)}
sage: S
{0, 1, 2, 4, 8, 9, 13, 15, 16}
sage: p = 123457
sage: S = {n^2 % p for n in range(p)}
sage: len(S)
61729
![]() | 3 | No.3 Revision |
Given that $(n + p) p)^2 = n^2 + 2np + p^2 = n^2 \mbox{ mod } p,youjusthavetocomputethenumbersn^2 \mbox{ mod } pforallintegersbetween0andp-1$. If you want to avoid repetitions, you just have to put them in a set. Here is how:
sage: p = 17
sage: S = {n^2 % p for n in range(p)}
sage: S
{0, 1, 2, 4, 8, 9, 13, 15, 16}
sage: p = 123457
sage: S = {n^2 % p for n in range(p)}
sage: len(S)
61729