  
  [1X4 [33X[0;0YNumber-theoretic functions[133X[101X
  
  
  [1X4.1 [33X[0;0YFunctions for integers[133X[101X
  
  [1X4.1-1 AllSmoothIntegers[101X
  
  [33X[1;0Y[29X[2XAllSmoothIntegers[102X( [3Xmaxp[103X, [3Xmaxn[103X ) [32X function[133X
  [33X[1;0Y[29X[2XAllSmoothIntegers[102X( [3XL[103X, [3Xmaxp[103X ) [32X function[133X
  
  [33X[0;0YThis function has been transferred from package [5XRCWA[105X.[133X
  
  [33X[0;0YThe  function  [10XAllSmoothIntegers([3Xmaxp[103X[10X,[3Xmaxn[103X[10X)[110X returns the list of all positive
  integers  less than or equal to [3Xmaxn[103X whose prime factors are all in the list
  [22XL = {p ~|~ p leqslant maxp, p~mboxprime }[122X.[133X
  
  [33X[0;0YIn  the  alternative  form, when [22XL[122X is a list of primes, the function returns
  the list of all positive integers whose prime factors lie in [22XL[122X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XAllSmoothIntegers( 3, 1000 );[127X[104X
    [4X[28X[ 1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, [128X[104X
    [4X[28X  108, 128, 144, 162, 192, 216, 243, 256, 288, 324, 384, 432, 486, 512, 576, [128X[104X
    [4X[28X  648, 729, 768, 864, 972 ][128X[104X
    [4X[25Xgap>[125X [27XAllSmoothIntegers( [5,11,17], 1000 );[127X[104X
    [4X[28X[ 1, 5, 11, 17, 25, 55, 85, 121, 125, 187, 275, 289, 425, 605, 625, 935 ][128X[104X
    [4X[25Xgap>[125X [27XLength( last );[127X[104X
    [4X[28X16[128X[104X
    [4X[25Xgap>[125X [27XList( [3..20], n -> Length( AllSmoothIntegers( [5,11,17], 10^n ) ) );[127X[104X
    [4X[28X[ 16, 29, 50, 78, 114, 155, 212, 282, 359, 452, 565, 691, 831, 992, 1173, [128X[104X
    [4X[28X  1374, 1595, 1843 ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X4.1-2 AllProducts[101X
  
  [33X[1;0Y[29X[2XAllProducts[102X( [3XL[103X, [3Xk[103X ) [32X function[133X
  
  [33X[0;0YThis function has been transferred from package [5XRCWA[105X.[133X
  
  [33X[0;0YThe  command  [10XAllProducts([3XL[103X[10X,[3Xk[103X[10X)[110X returns the list of all products of [3Xk[103X entries
  of  the  list [3XL[103X. Note that every ordering of the entries is used so that, in
  the commuting case, there are bound to be repetitions.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XAllProducts([1..4],3); [127X[104X
    [4X[28X[ 1, 2, 3, 4, 2, 4, 6, 8, 3, 6, 9, 12, 4, 8, 12, 16, 2, 4, 6, 8, 4, 8, 12, [128X[104X
    [4X[28X  16, 6, 12, 18, 24, 8, 16, 24, 32, 3, 6, 9, 12, 6, 12, 18, 24, 9, 18, 27, [128X[104X
    [4X[28X  36, 12, 24, 36, 48, 4, 8, 12, 16, 8, 16, 24, 32, 12, 24, 36, 48, 16, 32, [128X[104X
    [4X[28X  48, 64 ][128X[104X
    [4X[25Xgap>[125X [27XSet(last);            [127X[104X
    [4X[28X[ 1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 64 ][128X[104X
    [4X[25Xgap>[125X [27XAllProducts( [(1,2,3),(2,3,4)], 2 );[127X[104X
    [4X[28X[ (2,4,3), (1,2)(3,4), (1,3)(2,4), (1,3,2) ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X4.1-3 RestrictedPartitionsWithoutRepetitions[101X
  
  [33X[1;0Y[29X[2XRestrictedPartitionsWithoutRepetitions[102X( [3Xn[103X, [3XS[103X ) [32X function[133X
  
  [33X[0;0YThis function has been transferred from package [5XRCWA[105X.[133X
  
  [33X[0;0YFor  a  positive  integer  [3Xn[103X and a set of positive integers [3XS[103X, this function
  returns  the  list  of  partitions  of [3Xn[103X into distinct elements of [3XS[103X. Unlike
  [10XRestrictedPartitions[110X, no repetitions are allowed.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XRestrictedPartitions( 20, [4..10] );[127X[104X
    [4X[28X[ [ 4, 4, 4, 4, 4 ], [ 5, 5, 5, 5 ], [ 6, 5, 5, 4 ], [ 6, 6, 4, 4 ], [128X[104X
    [4X[28X  [ 7, 5, 4, 4 ], [ 7, 7, 6 ], [ 8, 4, 4, 4 ], [ 8, 6, 6 ], [ 8, 7, 5 ], [128X[104X
    [4X[28X  [ 8, 8, 4 ], [ 9, 6, 5 ], [ 9, 7, 4 ], [ 10, 5, 5 ], [ 10, 6, 4 ], [128X[104X
    [4X[28X  [ 10, 10 ] ][128X[104X
    [4X[25Xgap>[125X [27XRestrictedPartitionsWithoutRepetitions( 20, [4..10] );[127X[104X
    [4X[28X[ [ 10, 6, 4 ], [ 9, 7, 4 ], [ 9, 6, 5 ], [ 8, 7, 5 ] ][128X[104X
    [4X[25Xgap>[125X [27XRestrictedPartitionsWithoutRepetitions( 10^2, List([1..10], n->n^2 ) );[127X[104X
    [4X[28X[ [ 100 ], [ 64, 36 ], [ 49, 25, 16, 9, 1 ] ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X4.1-4 NextProbablyPrimeInt[101X
  
  [33X[1;0Y[29X[2XNextProbablyPrimeInt[102X( [3Xn[103X ) [32X function[133X
  
  [33X[0;0YThis function has been transferred from package [5XRCWA[105X.[133X
  
  [33X[0;0YThe function [10XNextProbablyPrimeInt([3Xn[103X[10X)[110X does the same as [10XNextPrimeInt([3Xn[103X[10X)[110X except
  that    for   reasons   of   performance   it   tests   numbers   only   for
  [10XIsProbablyPrimeInt([3Xn[103X[10X)[110X  instead  of [10XIsPrimeInt([3Xn[103X[10X)[110X. For large [3Xn[103X, this function
  is much faster than [10XNextPrimeInt([3Xn[103X[10X)[110X[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xn := 2^251;[127X[104X
    [4X[28X3618502788666131106986593281521497120414687020801267626233049500247285301248[128X[104X
    [4X[25Xgap>[125X [27XNextProbablyPrimeInt( n );[127X[104X
    [4X[28X3618502788666131106986593281521497120414687020801267626233049500247285301313[128X[104X
    [4X[25Xgap>[125X [27Xtime;                     [127X[104X
    [4X[28X1[128X[104X
    [4X[25Xgap>[125X [27XNextPrimeInt( n );        [127X[104X
    [4X[28X3618502788666131106986593281521497120414687020801267626233049500247285301313[128X[104X
    [4X[25Xgap>[125X [27Xtime;             [127X[104X
    [4X[28X213[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X4.1-5 PrimeNumbersIterator[101X
  
  [33X[1;0Y[29X[2XPrimeNumbersIterator[102X( [[3Xchunksize[103X] ) [32X function[133X
  
  [33X[0;0YThis function has been transferred from package [5XRCWA[105X.[133X
  
  [33X[0;0YThis  function  returns  an  iterator  which  runs  over the prime numbers n
  ascending order; it takes an optional argument [10Xchunksize[110X which specifies the
  length  of the interval which is sieved in one go (the default is [22X10^7[122X), and
  which  can  be used to balance runtime vs. memory consumption. It is assumed
  that  [10Xchunksize[110X is larger than any gap between two consecutive primes within
  the range one intends to run the iterator over.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xiter := PrimeNumbersIterator();;[127X[104X
    [4X[25Xgap>[125X [27Xfor i in [1..100] do  p := NextIterator(iter);  od;[127X[104X
    [4X[25Xgap>[125X [27Xp;[127X[104X
    [4X[28X541[128X[104X
    [4X[25Xgap>[125X [27Xsum := 0;;[127X[104X
    [4X[25Xgap>[125X [27X## "prime number race" 1 vs. 3 mod 4[127X[104X
    [4X[25Xgap>[125X [27Xfor p in PrimeNumbersIterator() do [127X[104X
    [4X[25X>[125X [27X      if p <> 2 then sum := sum + E(4)^(p-1); fi;[127X[104X
    [4X[25X>[125X [27X      if sum > 0 then break; fi;[127X[104X
    [4X[25X>[125X [27X   od;[127X[104X
    [4X[25Xgap>[125X [27Xp;[127X[104X
    [4X[28X26861[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
