Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/tst/testinstall/   (GAP Algebra Version 4.15.1©)  Datei vom 18.9.2025 mit Größe 22 kB image not shown  

Quelle  combinat.tst   Sprache: unbekannt

 
Spracherkennung für: .tst vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

#############################################################################
##
##  This  file  tests  the functions that  mainly  deal  with  combinatorics.
##
#@local n,mset,comb1,comb2,comb3,it,pn1,pn2,s,k,x

gap> START_TEST("combinat.tst");

#F  Factorial( <n> )  . . . . . . . . . . . . . . . . factorial of an integer
gap> Print(List( [0..10], Factorial ),"\n");
1126241207205040403203628803628800 ]
gap> Factorial( 50 );
30414093201713378043612608166064768844377641568960512000000000000
gap> Factorial(-1);
Error, Factorial: <n> must be a non-negative small integer (not the integer -1\
)
gap> Factorial(fail);
Error, Factorial: <n> must be a non-negative small integer (not the value 'fai\
l')

#F  Binomial( <n>, <k> )  . . . . . . . . .  binomial coefficient of integers
gap> Print(List( [-8..8], k -> Binomial( 0, k ) ),"\n");
00000000100000000 ]
gap> List( [-8..8], n -> Binomial( n, 0 ) );
11111111111111111 ]
gap> ForAll( [-8..8], n -> ForAll( [-2..8], k ->
>        Binomial(n,k) = Binomial(n-1,k) + Binomial(n-1,k-1) ) );
true
gap> Binomial( 40050 );
17035900270730601418919867558071677342938596450600561760371485120
gap> Binomial( -2^1001 ) = -2^100;
true
gap> Binomial( 2^1002 ) = 2^100 * (2^100 - 1) / 2;
true
gap> Binomial(fail, 0);
Error, Binomial: <n> must be an integer (not the value 'fail')
gap> Binomial(0, fail);
Error, Binomial: <k> must be an integer (not the value 'fail')

#F  Bell( <n> ) . . . . . . . . . . . . . . . . .  value of the Bell sequence
gap> Print(List( [0..10], n -> Bell(n) ),"\n");
11251552203877414021147115975 ]
gap> Print(List( [0..10], n -> Sum( [0..n], k -> Stirling2( n, k ) ) ),"\n");
11251552203877414021147115975 ]
gap> Bell( 60 );
976939307467007552986994066961675455550246347757474482558637

#F  Stirling1( <n>, <k> ) . . . . . . . . . Stirling number of the first kind
gap> Print(List( [-8..8], k -> Stirling1( 0, k ) ),"\n");
00000000100000000 ]
gap> Print(List( [-8..8], n -> Stirling1( n, 0 ) ),"\n");
00000000100000000 ]
gap> ForAll( [-8..8], n -> ForAll( [-8..8], k ->
>        Stirling1(n,k) = (n-1) * Stirling1(n-1,k) + Stirling1(n-1,k-1) ) );
true
gap> Stirling1( 6020 );
568611292461582075463109862277030309493811818619783570055397018154658816

#F  Stirling2( <n>, <k> ) . . . . . . . .  Stirling number of the second kind
gap> Print(List( [-8..8], k -> Stirling2( 0, k ) ),"\n");
00000000100000000 ]
gap> Print(List( [-8..8], n -> Stirling2( n, 0 ) ),"\n");
00000000100000000 ]
gap> ForAll( [-8..8], n -> ForAll( [-8..8], k ->
>        Stirling2(n,k) = k * Stirling2(n-1,k) + Stirling2(n-1,k-1) ) );
true
gap> Stirling2( 6020 );
170886257768137628374668205554120607567311094075812403938286

#F  Combinations( <mset>, <k> ) . . . .  set of sorted sublists of a multiset
gap> Combinations( [] );
[ [  ] ]
gap> Print(List( [0..1], k -> Combinations( [], k ) ),"\n");
[ [ [  ] ], [  ] ]
gap> Print(Combinations( [1..4] ),"\n");
[ [  ], [ 1 ], [ 12 ], [ 123 ], [ 1234 ], [ 124 ], [ 13 ], 
  [ 134 ], [ 14 ], [ 2 ], [ 23 ], [ 234 ], [ 24 ], [ 3 ], 
  [ 34 ], [ 4 ] ]
gap> Print(List( [0..5], k -> Combinations( [1..4], k ) ),"\n");
[ [ [  ] ], [ [ 1 ], [ 2 ], [ 3 ], [ 4 ] ], 
  [ [ 12 ], [ 13 ], [ 14 ], [ 23 ], [ 24 ], [ 34 ] ], 
  [ [ 123 ], [ 124 ], [ 134 ], [ 234 ] ], [ [ 1234 ] ], 
  [  ] ]
gap> Print(Combinations( [1,2,2,3] ),"\n");
[ [  ], [ 1 ], [ 12 ], [ 122 ], [ 1223 ], [ 123 ], [ 13 ], 
  [ 2 ], [ 22 ], [ 223 ], [ 23 ], [ 3 ] ]
gap> Print(List( [0..5], k -> Combinations( [1,2,2,3], k ) ),"\n");
[ [ [  ] ], [ [ 1 ], [ 2 ], [ 3 ] ], 
  [ [ 12 ], [ 13 ], [ 22 ], [ 23 ] ], 
  [ [ 122 ], [ 123 ], [ 223 ] ], [ [ 1223 ] ], [  ] ]
gap> Combinations( [1..12] )[4039];
789101112 ]
gap> Combinations( [1..16], 4 )[266];
15913 ]
gap> Combinations( [1,2,3,3,4,4,5,5,5,6,6,6,7,7,7,7] )[378];
1234567 ]
gap> Combinations( [1,2,3,3,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,8], 8 )[97];
12345678 ]

#F  NrCombinations( <mset>, <k> ) . . number of sorted sublists of a multiset
gap> NrCombinations( [] );
1
gap> Print(List( [0..1], k -> NrCombinations( [], k ) ),"\n");
10 ]
gap> NrCombinations( [1..4] );
16
gap> Print(List( [0..5], k -> NrCombinations( [1..4], k ) ),"\n");
146410 ]
gap> NrCombinations( [1,2,2,3] );
12
gap> Print(List( [0..5], k -> NrCombinations( [1,2,2,3], k ) ),"\n");
134310 ]
gap> NrCombinations( [1..12] );
4096
gap> NrCombinations( [1..16], 4 );
1820
gap> NrCombinations( [1,2,3,3,4,4,5,5,5,6,6,6,7,7,7,7] );
2880
gap> NrCombinations( [1,2,3,3,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,8], 8 );
1558

#F  IteratorOfCombinations( <mset>[, <k>] )
#F  EnumeratorOfCombinations( <mset> )
gap> for n in [ 0 .. 10 ] do
>      mset:= Union( [ 1 .. n ], [ 1 .. n ] );
>      comb1:= Combinations( mset );
>      comb2:= List( IteratorOfCombinations( mset ) );
>      comb3:= EnumeratorOfCombinations( mset );
>      if Length( Set( [ comb1, comb2, comb3 ], SortedList ) ) <> 1 then
>        Error( "different elements" );
>      fi;
>    od;

#F  Arrangements( <mset> )  . . . . set of ordered combinations of a multiset
gap> Arrangements( [] );
[ [  ] ]
gap> Print(List( [0..1], k -> Arrangements( [], k ) ),"\n");
[ [ [  ] ], [  ] ]
gap> Print(Arrangements( [1..3] ),"\n");
[ [  ], [ 1 ], [ 12 ], [ 123 ], [ 13 ], [ 132 ], [ 2 ], [ 21 ], 
  [ 213 ], [ 23 ], [ 231 ], [ 3 ], [ 31 ], [ 312 ], [ 32 ], 
  [ 321 ] ]
gap> Print(List( [0..4], k -> Arrangements( [1..3], k ) ),"\n");
[ [ [  ] ], [ [ 1 ], [ 2 ], [ 3 ] ], 
  [ [ 12 ], [ 13 ], [ 21 ], [ 23 ], [ 31 ], [ 32 ] ], 
  [ [ 123 ], [ 132 ], [ 213 ], [ 231 ], [ 312 ], 
      [ 321 ] ], [  ] ]
gap> Print(Arrangements( [1,2,2,3] ),"\n");
[ [  ], [ 1 ], [ 12 ], [ 122 ], [ 1223 ], [ 123 ], 
  [ 1232 ], [ 13 ], [ 132 ], [ 1322 ], [ 2 ], [ 21 ], 
  [ 212 ], [ 2123 ], [ 213 ], [ 2132 ], [ 22 ], 
  [ 221 ], [ 2213 ], [ 223 ], [ 2231 ], [ 23 ], 
  [ 231 ], [ 2312 ], [ 232 ], [ 2321 ], [ 3 ], [ 31 ], 
  [ 312 ], [ 3122 ], [ 32 ], [ 321 ], [ 3212 ], 
  [ 322 ], [ 3221 ] ]
gap> Print(List( [0..5], k -> Arrangements( [1,2,2,3], k ) ),"\n");
[ [ [  ] ], [ [ 1 ], [ 2 ], [ 3 ] ], 
  [ [ 12 ], [ 13 ], [ 21 ], [ 22 ], [ 23 ], [ 31 ], [ 32 ] ], 
  [ [ 122 ], [ 123 ], [ 132 ], [ 212 ], [ 213 ], 
      [ 221 ], [ 223 ], [ 231 ], [ 232 ], [ 312 ], 
      [ 321 ], [ 322 ] ], 
  [ [ 1223 ], [ 1232 ], [ 1322 ], [ 2123 ], 
      [ 2132 ], [ 2213 ], [ 2231 ], [ 2312 ], 
      [ 2321 ], [ 3122 ], [ 3212 ], [ 3221 ] ], [  ] ]
gap> Arrangements( [1..6] )[736];
321654 ]
gap> Arrangements( [1..8], 4 )[443];
3175 ]
gap> Arrangements( [1,2,3,3,4,4,5] )[3511];
54321 ]
gap> Arrangements( [1,2,3,4,4,5,5,6,6], 5 )[424];
23456 ]

#F  NrArrangements( <mset>, <k> ) . . number of sorted sublists of a multiset
gap> NrArrangements( [] );
1
gap> Print(List( [0..1], k -> NrArrangements( [], k ) ),"\n");
10 ]
gap> NrArrangements( [1..3] );
16
gap> Print(List( [0..4], k -> NrArrangements( [1..3], k ) ),"\n");
13660 ]
gap> NrArrangements( [1,2,2,3] );
35
gap> Print(List( [0..5], k -> NrArrangements( [1,2,2,3], k ) ),"\n");
13712120 ]
gap> NrArrangements( [1..6] );
1957
gap> NrArrangements( [1..8], 4 );
1680
gap> NrArrangements( [1,2,3,3,4,4,5] );
3592
gap> NrArrangements( [1,2,3,4,4,5,5,6,6], 5 );
2880

#F  UnorderedTuples( <set>, <k> ) . . . .  set of unordered tuples from a set
gap> Print(List( [0..1], k -> UnorderedTuples( [], k ) ),"\n");
[ [ [  ] ], [  ] ]
gap> Print(List( [0..4], k -> UnorderedTuples( [1..3], k ) ),"\n");
[ [ [  ] ], [ [ 1 ], [ 2 ], [ 3 ] ], 
  [ [ 11 ], [ 12 ], [ 13 ], [ 22 ], [ 23 ], [ 33 ] ], 
  [ [ 111 ], [ 112 ], [ 113 ], [ 122 ], [ 123 ], 
      [ 133 ], [ 222 ], [ 223 ], [ 233 ], [ 333 ] ], 
  [ [ 1111 ], [ 1112 ], [ 1113 ], [ 1122 ], 
      [ 1123 ], [ 1133 ], [ 1222 ], [ 1223 ], 
      [ 1233 ], [ 1333 ], [ 2222 ], [ 2223 ], 
      [ 2233 ], [ 2333 ], [ 3333 ] ] ]
gap> UnorderedTuples( [1..10], 6 )[1459];
1357910 ]

#F  NrUnorderedTuples( <set>, <k> ) . . number unordered of tuples from a set
gap> Print(List( [0..1], k -> NrUnorderedTuples( [], k ) ),"\n");
10 ]
gap> Print(List( [0..4], k -> NrUnorderedTuples( [1..3], k ) ),"\n");
1361015 ]
gap> NrUnorderedTuples( [1..10], 6 );
5005

#F  Tuples( <set>, <k> )  . . . . . . . . .  set of ordered tuples from a set
gap> Print(List( [0..1], k -> Tuples( [], k ) ),"\n");
[ [ [  ] ], [  ] ]
gap> Print(List( [0..3], k -> Tuples( [1..3], k ) ),"\n");
[ [ [  ] ], [ [ 1 ], [ 2 ], [ 3 ] ], 
  [ [ 11 ], [ 12 ], [ 13 ], [ 21 ], [ 22 ], [ 23 ], [ 31 ], 
      [ 32 ], [ 33 ] ], 
  [ [ 111 ], [ 112 ], [ 113 ], [ 121 ], [ 122 ], 
      [ 123 ], [ 131 ], [ 132 ], [ 133 ], [ 211 ], 
      [ 212 ], [ 213 ], [ 221 ], [ 222 ], [ 223 ], 
      [ 231 ], [ 232 ], [ 233 ], [ 311 ], [ 312 ], 
      [ 313 ], [ 321 ], [ 322 ], [ 323 ], [ 331 ], 
      [ 332 ], [ 333 ] ] ]
gap> Tuples( [1..8], 4 )[167];
1357 ]

#F  NrTuples( <set>, <k> )  . . . . . . . number of ordered tuples from a set
gap> Print(List( [0..1], k -> NrTuples( [], k ) ),"\n");
10 ]
gap> Print(List( [0..3], k -> NrTuples( [1..3], k ) ),"\n");
13927 ]
gap> NrTuples( [1..8], 4 );
4096

#
# IteratorOfCartesianProduct
#

# empty cartesian product
gap> it:=IteratorOfCartesianProduct([[1,2],[]]);;
gap> IsDoneIterator(it);
true
gap> List(it);
[  ]

# non-empty cartesian product
gap> it:=IteratorOfCartesianProduct([1,2], [3,4]);;
gap> IsDoneIterator(it);
false
gap> List(it);
[ [ 13 ], [ 14 ], [ 23 ], [ 24 ] ]
gap> List(it); # do it again, to verify the original iterator was not modified
[ [ 13 ], [ 14 ], [ 23 ], [ 24 ] ]

#F  PermutationsList( <mset> )  . . . . . . set of permutations of a multiset
gap> PermutationsList( [] );
[ [  ] ]
gap> Print(PermutationsList( [1..4] ),"\n");
[ [ 1234 ], [ 1243 ], [ 1324 ], [ 1342 ], 
  [ 1423 ], [ 1432 ], [ 2134 ], [ 2143 ], 
  [ 2314 ], [ 2341 ], [ 2413 ], [ 2431 ], 
  [ 3124 ], [ 3142 ], [ 3214 ], [ 3241 ], 
  [ 3412 ], [ 3421 ], [ 4123 ], [ 4132 ], 
  [ 4213 ], [ 4231 ], [ 4312 ], [ 4321 ] ]
gap> Print(PermutationsList( [1,2,2,3,] ),"\n");
[ [ 1223 ], [ 1232 ], [ 1322 ], [ 2123 ], 
  [ 2132 ], [ 2213 ], [ 2231 ], [ 2312 ], 
  [ 2321 ], [ 3122 ], [ 3212 ], [ 3221 ] ]
gap> Print(PermutationsList( [1..6] )[ 128 ],"\n");
214365 ]
gap> Print(PermutationsList( [1,2,2,3,3,4,4,4] )[1359],"\n");
43214324 ]

#F  NrPermutationsList( <mset> )  . . .  number of permutations of a multiset
gap> NrPermutationsList( [] );
1
gap> NrPermutationsList( [1..4] );
24
gap> NrPermutationsList( [1,2,2,3] );
12
gap> NrPermutationsList( [1..6] );
720
gap> NrPermutationsList( [1,2,2,3,3,4,4,4] );
1680

#F  Derangements( <list> ) . . . . set of fixpointfree permutations of a list
gap> Derangements( [] );
[ [  ] ]
gap> Print(Derangements( [1..4] ),"\n");
[ [ 2143 ], [ 2341 ], [ 2413 ], [ 3142 ], 
  [ 3412 ], [ 3421 ], [ 4123 ], [ 4312 ], 
  [ 4321 ] ]
gap> Print(Derangements( [1..6] )[ 128 ],"\n");
436125 ]
gap> Print(Derangements( [1,2,2,3,3,4,4,4] )[64],"\n");
41424233 ]

#F  NrDerangements( <list> ) .  number of fixpointfree permutations of a list
gap> NrDerangements( [] );
1
gap> NrDerangements( [1..4] );
9
gap> NrDerangements( [1..6] );
265
gap> NrDerangements( [1,2,2,3,3,4,4,4] );
126

#F  Permanent( <mat> )  . . . . . . . . . . . . . . . . permanent of a matrix
gap> Permanent( [[0,1,1,1],[1,0,1,1],[1,1,0,1],[1,1,1,0]] );
9
gap> Permanent( [[1,1,0,1,0,0,0],[0,1,1,0,1,0,0],[0,0,1,1,0,1,0],[0,0,0,1,1,0,1],
>                [1,0,0,0,1,1,0],[0,1,0,0,0,1,1],[1,0,1,0,0,0,1]] );
24

#F  PartitionsSet( <set> )  . . . . . . . . . . .  set of partitions of a set
gap> PartitionsSet( [] );
[ [  ] ]
gap> Print(List( [0..1], k -> PartitionsSet( [], k ) ),"\n");
[ [ [  ] ], [  ] ]
gap> Print(PartitionsSet( [1..4] ),"\n");
[ [ [ 1 ], [ 2 ], [ 3 ], [ 4 ] ], [ [ 1 ], [ 2 ], [ 34 ] ], 
  [ [ 1 ], [ 23 ], [ 4 ] ], [ [ 1 ], [ 234 ] ], 
  [ [ 1 ], [ 24 ], [ 3 ] ], [ [ 12 ], [ 3 ], [ 4 ] ], 
  [ [ 12 ], [ 34 ] ], [ [ 123 ], [ 4 ] ], [ [ 1234 ] ], 
  [ [ 124 ], [ 3 ] ], [ [ 13 ], [ 2 ], [ 4 ] ], [ [ 13 ], [ 24 ] ], 
  [ [ 134 ], [ 2 ] ], [ [ 14 ], [ 2 ], [ 3 ] ], [ [ 14 ], [ 23 ] ] ]
gap> Print(List( [0..4], k -> PartitionsSet( [1..3], k ) ),"\n");
[ [  ], [ [ [ 123 ] ] ], 
  [ [ [ 1 ], [ 23 ] ], [ [ 12 ], [ 3 ] ], [ [ 13 ], [ 2 ] ] ], 
  [ [ [ 1 ], [ 2 ], [ 3 ] ] ], [  ] ]
gap> Print(PartitionsSet( [1..7] )[521],"\n");
[ [ 1357 ], [ 246 ] ]
gap> Print(PartitionsSet( [1..8], 3 )[96],"\n");
[ [ 123 ], [ 45 ], [ 678 ] ]

#F  NrPartitionsSet( <set> )  . . . . . . . . . number of partitions of a set
gap> NrPartitionsSet( [] );
1
gap> List( [0..1], k -> NrPartitionsSet( [], k ) );
10 ]
gap> NrPartitionsSet( [1..4] );
15
gap> Print(List( [0..4], k -> NrPartitionsSet( [1,2,3], k ) ),"\n");
01310 ]
gap> NrPartitionsSet( [1..8] );
4140
gap> NrPartitionsSet( [1..9], 3 );
3025

#F  Partitions( <n> ) . . . . . . . . . . . . set of partitions of an integer
gap> Partitions( 0 );
[ [  ] ]
gap> List( [0..1], k -> Partitions( 0, k ) );
[ [ [  ] ], [  ] ]
gap> Print(Partitions( 6 ),"\n");
[ [ 111111 ], [ 21111 ], [ 2211 ], [ 222 ], 
  [ 3111 ], [ 321 ], [ 33 ], [ 411 ], [ 42 ], [ 51 ], 
  [ 6 ] ]
gap> Print(List( [0..7], k -> Partitions( 6, k ) ),"\n");
[ [  ], [ [ 6 ] ], [ [ 33 ], [ 42 ], [ 51 ] ], 
  [ [ 222 ], [ 321 ], [ 411 ] ], 
  [ [ 2211 ], [ 3111 ] ], [ [ 21111 ] ], 
  [ [ 111111 ] ], [  ] ]
gap> Partitions( 20 )[314];
743321 ]
gap> Partitions( 2010 )[17];
5332211111 ]

#F  NrPartitions( <n> ) . . . . . . . . .  number of partitions of an integer
gap> NrPartitions( 0 );
1
gap> List( [0..1], k -> NrPartitions( 0, k ) );
10 ]
gap> NrPartitions( 6 );
11
gap> List( [0..7], k -> NrPartitions( 6, k ) );
01332110 ]
gap> NrPartitions( 100 );
190569292
gap> NrPartitions( 10010 );
2977866

#F  OrderedPartitions( <n> ) . . . .  set of ordered partitions of an integer
gap> OrderedPartitions( 0 );
[ [  ] ]
gap> List( [0..1], k -> OrderedPartitions( 0, k ) );
[ [ [  ] ], [  ] ]
gap> Print(OrderedPartitions( 5 ),"\n");
[ [ 11111 ], [ 1112 ], [ 1121 ], [ 113 ], 
  [ 1211 ], [ 122 ], [ 131 ], [ 14 ], [ 2111 ], 
  [ 212 ], [ 221 ], [ 23 ], [ 311 ], [ 32 ], [ 41 ], [ 5 ] ]
gap> Print(List( [0..6], k -> OrderedPartitions( 5, k ) ),"\n");
[ [  ], [ [ 5 ] ], [ [ 14 ], [ 23 ], [ 32 ], [ 41 ] ], 
  [ [ 113 ], [ 122 ], [ 131 ], [ 212 ], [ 221 ], 
      [ 311 ] ], 
  [ [ 1112 ], [ 1121 ], [ 1211 ], [ 2111 ] ], 
  [ [ 11111 ] ], [  ] ]
gap> OrderedPartitions( 13 )[2048];
112 ]
gap> OrderedPartitions( 166 )[1001];
1111111 ]

#F  NrOrderedPartitions( <n> ) . . number of ordered partitions of an integer
gap> NrOrderedPartitions( 0 );
1
gap> List( [0..1], k -> NrOrderedPartitions( 0, k ) );
10 ]
gap> NrOrderedPartitions( 5 );
16
gap> List( [0..6], k -> NrOrderedPartitions( 5, k ) );
0146410 ]
gap> NrOrderedPartitions( 13 );
4096
gap> NrOrderedPartitions( 166 );
3003

#F  RestrictedPartitions( <n>, <set> )  . restricted partitions of an integer
gap> RestrictedPartitions( 0, [1..10] );
[ [  ] ]
gap> List( [0..1], k -> RestrictedPartitions( 0, [1..10], k ) );
[ [ [  ] ], [  ] ]
gap> Print(RestrictedPartitions( 10, [1,2,5,10] ),"\n");
[ [ 1111111111 ], [ 211111111 ], 
  [ 22111111 ], [ 2221111 ], [ 222211 ], 
  [ 22222 ], [ 511111 ], [ 52111 ], [ 5221 ], 
  [ 55 ], [ 10 ] ]
gap> Print(List( [1..10],k->RestrictedPartitions( 10, [1,2,5,10], k )),"\n");
[ [ [ 10 ] ], [ [ 55 ] ], [  ], [ [ 5221 ] ], 
  [ [ 22222 ], [ 52111 ] ], 
  [ [ 222211 ], [ 511111 ] ], [ [ 2221111 ] ],
  [ [ 22111111 ] ], [ [ 211111111 ] ], 
  [ [ 1111111111 ] ] ]
gap> Print(RestrictedPartitions( 20, [2,5,10] ),"\n");
[ [ 2222222222 ], [ 5522222 ], [ 5555 ], 
  [ 1022222 ], [ 1055 ], [ 1010 ] ]
gap> Print(List( [1..20], k -> RestrictedPartitions( 20, [2,5,10],k)),"\n");
[ [  ], [ [ 1010 ] ], [ [ 1055 ] ], [ [ 5555 ] ], [  ], 
  [ [ 1022222 ] ], [ [ 5522222 ] ], [  ], [  ], 
  [ [ 2222222222 ] ], [  ], [  ], [  ], [  ], [  ], [  ], 
  [  ], [  ], [  ], [  ] ]
gap> Print(RestrictedPartitions( 60, [2,3,5,7,11,13,17] )[600],"\n");
13755552222222222 ]
gap> Print(RestrictedPartitions( 100, [2,3,5,7,11,13,17], 10 )[75],"\n");
171713131375555 ]

#F  NrRestrictedPartitions(<n>,<set>) . . . . number of restricted partitions
gap> NrRestrictedPartitions( 0, [1..10] );
1
gap> List( [0..1], k -> NrRestrictedPartitions( 0, [1..10], k ) );
10 ]
gap> NrRestrictedPartitions( 50, [1,2,5,10] );
341
gap> Print(List( [1..50], k->NrRestrictedPartitions( 50, [1,2,5,10], k)),"\n");
00001112466810111112131414141515
  141414131212111099876665444322
  221111 ]
gap> NrRestrictedPartitions( 50, [2,5,10] );
21
gap> Print(List( [1..50],k -> NrRestrictedPartitions( 50, [2,5,10],k)),"\n");
0000111122112111111011001
  0000000000000000000000000 ]
gap> NrRestrictedPartitions( 60, [2,3,5,7,11,13,17] );
1213
gap> NrRestrictedPartitions( 100, [2,3,5,7,11,13,17], 10 );
125

#F  IteratorOfPartitions( <n> )
gap> IteratorOfPartitions(fail);
Error, <n> must be a nonnegative integer
gap> for n in [ 0 .. 15 ] do
>      pn1:= Partitions( n );
>      pn2:= List( IteratorOfPartitions( n ) );
>      if Length(pn1) <> Length(pn2) then
>        Error( "wrong number of elements" );
>      elif pn1 <> pn2 then
>        Error( "different elements" );
>      fi;
>    od;

#F  IteratorOfPartitionsSet( <set> [, <k> [, <flag> ] ] )
gap> IteratorOfPartitionsSet();
Error, Function: number of arguments must be at least 1 (not 0)
gap> IteratorOfPartitionsSet(fail);
Error, IteratorOfPartitionsSet: <s> must be a set
gap> IteratorOfPartitionsSet([],fail);
Error, IteratorOfPartitionsSet: <k> must be an integer
gap> IteratorOfPartitionsSet([1],1,fail);
Error, IteratorOfPartitionsSet: <flag> must be true or false
gap> IteratorOfPartitionsSet([1],1,true,"too many");
Error, usage: IteratorOfPartitionsSet( <set> [, <k> [, <flag> ] ] )
gap> for s in [[], [5], [1,2,3,4], [2,5,7], ["a","b","c","d","e"], [3..9]] do
>      pn1:= PartitionsSet( s );
>      pn2:= List( IteratorOfPartitionsSet( s ) );
>      if Length(pn1) <> Length(pn2) then
>        Error( "wrong number of elements for s = ", s );
>      elif Set(pn1) <> Set(pn2) then
>        Error( "different elements for s = ", s );
>      fi;
>      for k in [0 .. Size(s)+1] do
>        pn1:= PartitionsSet( s, k );
>        pn2:= List( IteratorOfPartitionsSet( s, k ) );
>        if Length(pn1) <> Length(pn2) then
>          Error( "wrong number of elements for s = ", s, ", k = ", k );
>        elif Set(pn1) <> Set(pn2) then
>          Error( "different elements for s = ", s, ", k = ", k );
>        fi;
>      od; 
>      for k in [0 .. Size(s) + 1] do
>        pn1:= [];
>        for x in [0 .. k] do
>          Append( pn1, PartitionsSet( s, x ) );
>        od;
>        pn2:= List( IteratorOfPartitionsSet( s, k, true ) );
>        if Length(pn1) <> Length(pn2) then
>          Error( "wrong number of elements for s = ", s, ", k <= ", k );
>        elif Set(pn1) <> Set(pn2) then
>          Error( "different elements for s = ", s, ", k <= ", k );
>        fi;
>      od;
>    od;

#F  Lucas(<P>,<Q>,<k>)  . . . . . . . . . . . . . . value of a lucas sequence
gap> Print(List( [0..10], i->Lucas(1,-2,i)[1] ),"\n");
0113511214385171341 ]
gap> Print(List( [0..10], i->Lucas(1,-2,i)[2] ),"\n");
21571731651272575111025 ]
gap> Print(List( [0..10], i->Lucas(1,-1,i)[1] ),"\n");
011235813213455 ]
gap> Print(List( [0..10], i->Lucas(2,1,i)[1] ),"\n");
012345678910 ]
gap> Lucas( 0, -4100 ) = [ 02^1014^100 ];
true

#F  Fibonacci( <n> )  . . . . . . . . . . . . value of the Fibonacci sequence
gap> Print(List( [0..17], Fibonacci ),"\n");
011235813213455891442333776109871597 ]
gap> Fibonacci( 333 );
1751455877444438095408940282208383549115781784912085789506677971125378

#F  Bernoulli( <n> )  . . . . . . . . . . . . value of the Bernoulli sequence
gap> Print(List( [0..14], Bernoulli ),"\n");
1, -1/21/60, -1/3001/420, -1/3005/660, -691/273007/6 ]
gap> Bernoulli( 80 );
-4603784299479457646935574969019046849794257872751288919656867/230010

# AssociatedPartition
gap> AssociatedPartition([]);
[  ]
gap> AssociatedPartition(Concatenation([7],ListWithIdenticalEntries(99,1)));
100111111 ]

# that's it for the combinatorial package  ##################################
gap> STOP_TEST("combinat.tst");

[Dauer der Verarbeitung: 0.18 Sekunden, vorverarbeitet 2026-06-13]