| 1 | #include "../code/mathematics/is_prime.cpp" |
| 2 | void test() { |
| 3 | // Field testing: Project Euler 437 |
| 4 | rep(it,0,10000) { |
| 5 | int n; |
| 6 | while (true) { |
| 7 | n = randint(2, 100000); |
| 8 | if (is_prime(n)) { |
| 9 | break; |
| 10 | } |
| 11 | } |
| 12 | int a; |
| 13 | while (true) { |
| 14 | a = randint(1,n-1); |
| 15 | if (leg(a, n) == 1) { |
| 16 | break; |
| 17 | } |
| 18 | } |
| 19 | ll res = tonelli_shanks(a, n); |
| 20 | assert_false(res == -1); |
| 21 | assert_equal<ll>(a, (res*res)%n); |
| 22 | } |
| 23 | } |
| 24 | // vim: cc=60 ts=2 sts=2 sw=2: |
nothing calls this directly
no test coverage detected