1gap> START_TEST("integers.tst");
2
3#
4gap> Basis(Integers);
5CanonicalBasis( Integers )
6gap> CanonicalBasis(Integers);
7CanonicalBasis( Integers )
8gap> Coefficients(Basis(Integers), 5);
9[ 5 ]
10gap> Coefficients(Basis(Integers), 5/2);
11fail
12
13#
14gap> BestQuoInt(5, 3);
152
16gap> BestQuoInt(-5, 3);
17-2
18gap> BestQuoInt(-5, -3);
192
20gap> BestQuoInt(5, -3);
21-2
22
23#
24gap> QuoInt(5, 3);
251
26gap> QuoInt(-5, 3);
27-1
28gap> QuoInt(-5, -3);
291
30gap> QuoInt(5, -3);
31-1
32
33#
34gap> RoundCyc(3);
353
36gap> RoundCycDown(3);
373
38
39#
40gap> PrimeDivisors(0);
41Error, <n> must be non zero
42gap> List([1..10], PrimeDivisors);
43[ [  ], [ 2 ], [ 3 ], [ 2 ], [ 5 ], [ 2, 3 ], [ 7 ], [ 2 ], [ 3 ], [ 2, 5 ] ]
44gap> last = List([1..10], n->PrimeDivisors(-n));
45true
46
47#
48gap> n:=(2^31-1)*(2^61-1);; # product of two "small" primes
49gap> PartialFactorization(n);
50[ 2147483647, 2305843009213693951 ]
51gap> FactorsInt(n);
52[ 2147483647, 2305843009213693951 ]
53gap> n:=2^155-19;; # not a prime; GAP fails to fully factorize it, though FactInt finds all 4 factors
54gap> PartialFactorization(n);
55[ 167, 273484587823896504154881143846609846492502347 ]
56gap> n:=(2^2203-1)*(2^2281-1);;  # product of two "large" primes
57gap> PartialFactorization(n) = [ n ];
58true
59gap> n:=2^255-19;; # this is a "large" prime for which GAP only knows it is probably prime
60gap> PartialFactorization(n) = [ n ];
61true
62gap> FactorsInt(n) = [ n ];
63#I  FactorsInt: used the following factor(s) which are probably primes:
64#I        57896044618658097711785492504343953926634992332820282019728792003956564819949
65true
66
67#
68gap> StringPP(-3);
69"-3"
70gap> StringPP(0);
71"0"
72gap> StringPP(-10);
73"-2*5"
74gap> StringPP(10);
75"2*5"
76gap> StringPP(10000);
77"2^4*5^4"
78
79#
80gap> Filtered([-4..20], IsPrimePowerInt);
81[ -3, -2, 2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19 ]
82gap> IsPrimePowerInt(1009^1009);
83true
84gap> IsPrimePowerInt(1009^1009*1013);
85false
86
87#
88gap> LogInt(0, 2);
89Error, <n> must be a positive integer
90gap> LogInt(1, 1);
91Error, <base> must be an integer greater than 1
92gap> ForAll([2,8,16,10,10000, 2^64], b->
93>   List([ 1, b-1, b, b+1, b^2-1, b^2, b^2+1 ], n->LogInt(n,b))
94>      = [ 0,   0, 1,   1,     1,   2,     2 ]);
95true
96
97#
98gap> List([-8..8], NextPrimeInt);
99[ -7, -5, -5, -3, -3, -2, 2, 2, 2, 2, 3, 5, 5, 7, 7, 11, 11 ]
100gap> List([-8..8], PrevPrimeInt);
101[ -11, -11, -7, -7, -5, -5, -3, -2, -2, -2, -2, 2, 3, 3, 5, 5, 7 ]
102
103#
104gap> PrimePowersInt(180);
105[ 2, 2, 3, 2, 5, 1 ]
106gap> PrimePowersInt(1);
107[  ]
108gap> PrimePowersInt(2);
109[ 2, 1 ]
110gap> PrimePowersInt(0);
111Error, <n> must be non zero
112
113#
114gap> EuclideanDegree(Integers, -5);
1155
116gap> EuclideanDegree(Integers, 0);
1170
118gap> EuclideanDegree(Integers, 5);
1195
120
121#
122gap> EuclideanQuotient(5, 3);
1231
124gap> EuclideanQuotient(-5, 3);
125-1
126gap> EuclideanQuotient(-5, -3);
1271
128gap> EuclideanQuotient(5, -3);
129-1
130
131#
132gap> EuclideanRemainder(5, 3);
1332
134gap> EuclideanRemainder(-5, 3);
135-2
136gap> EuclideanRemainder(-5, -3);
137-2
138gap> EuclideanRemainder(5, -3);
1392
140
141#
142gap> iter := Iterator(Integers);
143<iterator of Integers at 0>
144gap> List([1..10], i -> NextIterator(iter));
145[ 0, 1, -1, 2, -2, 3, -3, 4, -4, 5 ]
146gap> it2 := ShallowCopy(iter);
147<iterator of Integers at 5>
148gap> NextIterator(iter);
149-5
150gap> it2;
151<iterator of Integers at 5>
152gap> iter;
153<iterator of Integers at -5>
154
155#
156gap> iter := Iterator(PositiveIntegers);
157<iterator>
158gap> List([1..10], i -> NextIterator(iter));
159[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
160gap> it2 := ShallowCopy(iter);
161<iterator>
162gap> NextIterator(iter);
16311
164gap> NextIterator(it2);
16511
166
167#
168gap> List([-1,0,1,5/2], i -> i in Integers);
169[ true, true, true, false ]
170gap> List([-1,0,1,5/2], i -> i in PositiveIntegers);
171[ false, false, true, false ]
172gap> List([-1,0,1,5/2], i -> i in NonnegativeIntegers);
173[ false, true, true, false ]
174
175#
176gap> Iterator(5);
177Error, You cannot loop over the integer 5 did you mean the range [1..5]
178gap> for x in 5 do od;
179Error, You cannot loop over the integer 5 did you mean the range [1..5]
180
181#
182gap> STOP_TEST("integers.tst", 1);
183