-
Notifications
You must be signed in to change notification settings - Fork 0
/
b.sf
33 lines (25 loc) · 936 Bytes
/
b.sf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/ruby
# https://oeis.org/A309285
# a(6) <= 35141256146761030267, a(7) <= 4951782572086917319747. - ~~~~
# A309285(6) <= 35141256146761030267
# A309285(7) <= 4951782572086917319747
func isok_a(n, k) {
# prime(n)^((k-1)/2) == -1 (mod k)
powmod(prime(n), ((k-1)/2), k) == 1 && (
primes(prime(n)-1) -> all {|b|
powmod(b, (k-1)/2, k).is_congruent(-1, k)
}
)
}
#~ var n = 1
#~ for k in (1..1e6) {
#~ k.is_composite || next
#~ if (isok_a(n, k)) {
#~ say "a(#{n}) = #{k}"
#~ ++n
#~ }
#~ }
say isok_a(7, 4951782572086917319747)
# isok(n,k) = (k%2==1) && !isprime(k) && Mod(prime(n), k)^((k-1)/2) == Mod(1, k) && !forprime(q=2, prime(n)-1, if(Mod(q, k)^((k-1)/2) != Mod(-1, k), return(0)));
# a(n) = for(k=9, oo, if(isok(n, k), return(k))); \\ ~~~~
# b^((a(n)-1)/2) == (b/a(n)) (mod a(n)) for every natural b <= prime(n), where (x/y) is the Jacobi symbol.