1############################################################################## 2## 3#W number.tst Utils Package Stefan Kohl 4## 5#Y Copyright (C) 2015-2018, The GAP Group 6## 7 8gap> ReadPackage( "utils", "tst/loadall.g" );; 9gap> UtilsLoadingComplete; 10true 11 12## SubSection 4.1.1 13gap> AllSmoothIntegers( 3, 1000 ); 14[ 1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 15 108, 128, 144, 162, 192, 216, 243, 256, 288, 324, 384, 432, 486, 512, 576, 16 648, 729, 768, 864, 972 ] 17gap> AllSmoothIntegers( [5,11,17], 1000 ); 18[ 1, 5, 11, 17, 25, 55, 85, 121, 125, 187, 275, 289, 425, 605, 625, 935 ] 19gap> Length( last ); 2016 21gap> List( [3..20], n -> Length( AllSmoothIntegers( [5,11,17], 10^n ) ) ); 22[ 16, 29, 50, 78, 114, 155, 212, 282, 359, 452, 565, 691, 831, 992, 1173, 23 1374, 1595, 1843 ] 24 25## SubSection 4.1.2 26gap> AllProducts([1..4],3); 27[ 1, 2, 3, 4, 2, 4, 6, 8, 3, 6, 9, 12, 4, 8, 12, 16, 2, 4, 6, 8, 4, 8, 12, 28 16, 6, 12, 18, 24, 8, 16, 24, 32, 3, 6, 9, 12, 6, 12, 18, 24, 9, 18, 27, 29 36, 12, 24, 36, 48, 4, 8, 12, 16, 8, 16, 24, 32, 12, 24, 36, 48, 16, 32, 30 48, 64 ] 31gap> Set(last); 32[ 1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 64 ] 33gap> AllProducts( [(1,2,3),(2,3,4)], 2 ); 34[ (2,4,3), (1,2)(3,4), (1,3)(2,4), (1,3,2) ] 35 36## SubSection 4.1.3 37gap> RestrictedPartitions( 20, [4..10] ); 38[ [ 4, 4, 4, 4, 4 ], [ 5, 5, 5, 5 ], [ 6, 5, 5, 4 ], [ 6, 6, 4, 4 ], 39 [ 7, 5, 4, 4 ], [ 7, 7, 6 ], [ 8, 4, 4, 4 ], [ 8, 6, 6 ], [ 8, 7, 5 ], 40 [ 8, 8, 4 ], [ 9, 6, 5 ], [ 9, 7, 4 ], [ 10, 5, 5 ], [ 10, 6, 4 ], 41 [ 10, 10 ] ] 42gap> RestrictedPartitionsWithoutRepetitions( 20, [4..10] ); 43[ [ 10, 6, 4 ], [ 9, 7, 4 ], [ 9, 6, 5 ], [ 8, 7, 5 ] ] 44gap> RestrictedPartitionsWithoutRepetitions( 10^2, List([1..10], n->n^2 ) ); 45[ [ 100 ], [ 64, 36 ], [ 49, 25, 16, 9, 1 ] ] 46 47## SubSection 4.1.4 48gap> n := 2^251;; 49gap> NextProbablyPrimeInt( n ); 503618502788666131106986593281521497120414687020801267626233049500247285301313 51 52## SubSection 4.1.6 53gap> iter := PrimeNumbersIterator();; 54gap> for i in [1..100] do p := NextIterator(iter); od; 55gap> p; 56541 57gap> sum := 0;; 58gap> ## "prime number race" 1 vs. 3 mod 4 59gap> for p in PrimeNumbersIterator() do 60> if p <> 2 then sum := sum + E(4)^(p-1); fi; 61> if sum > 0 then break; fi; 62> od; 63gap> p; 6426861 65 66## this final example takes quite a while: use examples/number.g 67## gap> sum := 0;; 68## gap> ## "prime number race" 1 vs. 5 mod 8 69## gap> for p in PrimeNumbersIterator() do 70## > if p mod 8 in [1,5] then sum := sum + E(4)^((p-1)/2); fi; 71## > if sum > 0 then break; fi; 72## > od; 73## gap> p; 74## 588067889 75 76############################################################################# 77## 78#E number.tst . . . . . . . . . . . . . . . . . . . . . . . . . . ends here 79