Number-theoretic functions
Functions for integers This function is in the process of being transferred from package &RCWA;: for now you should &LoadRCWA; in order to use it.

The function AllSmoothIntegers(maxp,maxn) returns a list of all integers less than or equal to maxn which do not have prime divisors exceeding maxp.

gap> AllSmoothIntegers( 7, 100 ); [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 40, 42, 45, 48, 49, 50, 54, 56, 60, 63, 64, 70, 72, 75, 80, 81, 84, 90, 96, 98, 100 ] gap> Length(last); 46
This function has been transferred from package &RCWA;.

The command AllProducts(L,k) returns the list of all products of k entries of the list L. Note that every ordering of the entries is used so that, in the commuting case, there are bound to be repetitions.

gap> AllProducts([1..4],3); [ 1, 2, 3, 4, 2, 4, 6, 8, 3, 6, 9, 12, 4, 8, 12, 16, 2, 4, 6, 8, 4, 8, 12, 16, 6, 12, 18, 24, 8, 16, 24, 32, 3, 6, 9, 12, 6, 12, 18, 24, 9, 18, 27, 36, 12, 24, 36, 48, 4, 8, 12, 16, 8, 16, 24, 32, 12, 24, 36, 48, 16, 32, 48, 64 ] gap> Set(last); [ 1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 64 ] gap> AllProducts( [(1,2,3),(2,3,4)], 2 ); [ (2,4,3), (1,2)(3,4), (1,3)(2,4), (1,3,2) ]
This function is in the process of being transferred from package &RCWA;: for now you should &LoadRCWA; in order to use it.

Given a positive integer n and a set of positive integers S, this function returns a list of all partitions of n into distinct elements of S. The only difference to RestrictedPartitions is that no repetitions are allowed.

gap> RestrictedPartitions( 20, [4..10] ); [ [ 4, 4, 4, 4, 4 ], [ 5, 5, 5, 5 ], [ 6, 5, 5, 4 ], [ 6, 6, 4, 4 ], [ 7, 5, 4, 4 ], [ 7, 7, 6 ], [ 8, 4, 4, 4 ], [ 8, 6, 6 ], [ 8, 7, 5 ], [ 8, 8, 4 ], [ 9, 6, 5 ], [ 9, 7, 4 ], [ 10, 5, 5 ], [ 10, 6, 4 ], [ 10, 10 ] ] gap> RestrictedPartitionsWithoutRepetitions( 20, [4..10] ); [ [ 10, 6, 4 ], [ 9, 7, 4 ], [ 9, 6, 5 ], [ 8, 7, 5 ] ]
This function is in the process of being transferred from package &RCWA;: for now you should &LoadRCWA; in order to use it.

The function ExponentOfPrime(n,p) returns the exponent of the prime p in the prime factorization of n.

gap> ExponentOfPrime( 13577531, 11 ); 3
This function is in the process of being transferred from package &RCWA;: for now you should &LoadRCWA; in order to use it.

The function NextProbablyPrimeInt(n) does the same as NextPrimeInt(n) except that for reasons of performance it tests numbers only for IsProbablyPrimeInt(n) instead of IsPrimeInt(n). For large n, this function is much faster than NextPrimeInt(n)

gap> n := 2^251; 3618502788666131106986593281521497120414687020801267626233049500247285301248 gap> time; 0 gap> NextProbablyPrimeInt( n ); 3618502788666131106986593281521497120414687020801267626233049500247285301313 gap> time; 1 gap> NextPrimeInt( n ); 3618502788666131106986593281521497120414687020801267626233049500247285301313 gap> time; 12346
This function is in the process of being transferred from package &RCWA;: for now you should &LoadRCWA; in order to use it.

This function returns an iterator which runs over the prime numbers n ascending order; it takes an optional argument chunksize which specifies the length of the interval which is sieved in one go (the default is 10^7), and which can be used to balance runtime vs. memory consumption. It is assumed that chunksize is larger than any gap between two consecutive primes within the range one intends to run the iterator over.

gap> iter := PrimeNumbersIterator(); <iterator> gap> NextIterator( iter ); 2