/* Rechnen mit ganzen Zahlen */


a := 17; b := 4;
q, r := Quotrem(a,b);              /* Teilen mit Rest */
q; r;


GCD(100, 202);                     /* ggT */
GCD([12,3,1,5]);

m := 490742190714294; n := 921034721984710924371;
d, a, b := XGCD(m, n);d;a;b;
d eq a*m + b*n;

Factorial(123);
IsPrime(101);
n := 2347632987623984762349865238475239856982356;
IsPrime(n);

Factorization(n);
PrimesUpTo(100);
PrimeDivisors(n);


p := 17;
R := ResidueClassRing(p);
R;
bool,b := IsInvertible(R!a);
a*b eq One(R);
[IsInvertible(a) : a in R];


m:=26;
R := ResidueClassRing(m);
for a:=1 to m-1 do
    print "a = ", a, ".....", IsInvertible(R!a);
end for;
/* Übung: Stellen Sie eine Vermutung auf, welche a in Z/m invertierbar sind. */

for m:=2 to 20 do
R := ResidueClassRing(m);
    print "m = ", m, ".....", IsField(R);
end for;


/* Endliche Körper */
F := FiniteField(5);
F;
[a : a in F];

F := FiniteField(10);
F := FiniteField(25);
F;
[a : a in F];


/* Polynomringe */
P<x> := PolynomialRing(Integers());
f := x^3+3*x+1;
Degree(f);
HasRoot(f);
f := x^3+3*x;
Degree(f);
HasRoot(f);


