Shared2015-01-30-104847.sagewsOpen in CoCalc
Author: Paul Zeitz
Views : 4
3
3
p=11 a=8 sum =0 h=(p-1)/2 for k in [1..h]: if k*a/p-floor(k*a/p)>1/2: sum += 1 print legendre_symbol(a,p)==(-1)^sum
True
sum
3
int(mod(32,11))+3
13
mod(32,11)>5
True
legendre_symbol(5,29)
1
for k in [1..14]: if mod(k^2,29)==5: print k, k^2
11 121
173.is_prime()
True
p = 17 a = 2 val = 0 h = (p-1)/2 for k in [1..h]: if mod(k^2,p) == a: val = 1 print val
1
legendre_symbol(7,11)
-1
sigma(9)
13
sigma(100)
217
sigma(32)
63
def mif(f,n): sum = 0 for d in n.divisors(): sum += moebius(d)*f(n/d) return sum
mif(sigma,4)
4
def sq(n): return n^2
mif(sq,7)
48
mif(sq,2)
3
mif(sq,75)
4800
p=107 a=6 sum=0 for k in [1..(p-1)]: sum += legendre_symbol(k,p) sum
0
133.is_prime()
False
d=210 l = 10 n=100 P=Primes() for k in range(n): val =P.unrank(k) start=val tVal = True for m in [1..(l-1)]: val += d tVal *= val.is_prime() if tVal: print start
199
7 37 67 97 127 127.is_prime()
7 37 67 97 127 True
199+9*210
2089
2089.is_prime()
True
400-121
279
factor(279)
3^2 * 31
(109+1)/2
55
2*54*55
5940
5940^2+109^2
35295481
sqrt(35295481 )
5941
4892*11
53812
legendre_symbol(23,29)
1
n= 29*37
n
1073
x=100 y=mod(100^13,n) y
618
mod(618^853,1073)
100