Windows installer: update wxMaxima.
[maxima/cygwin.git] / tests / rtestifactor.mac
blob8e419ee0579ebe1f855dca4d99600f1dd1bf9e35
1 /* kill(all); */
2 /* done; */
4 /* PRIMALITY TESTS */
6 /* 0 and 1 are not primes */
7 primep(0);
8 false;
10 primep(1);
11 false;
13 primep(2);
14 true;
16 primep(6);
17 false;
19 /* this is checked from the list of small primes */
20 primep(1741);
21 true;
23 primep(8989);
24 false;
26 /* this is the deterministic primality test */
27 primep(1738727);
28 true;
30 primep(5178997768267);
31 false;
33 next_prime(100002100000);
34 100002100043;
36 prev_prime(100002100042);
37 100002099971;
39 /* Bug reported on mailing list by Walter Faxon on October 25th, 2017: "Bug in Maxima function primes()" */
40 [primes(10005, 10009), primes(10006, 10009), primes(10007, 10009), primes(10008, 10009), primes(10009, 10009), primes(10010, 10010), primes(9972, 10007), primes(9973, 10007), primes(1, 2), primes(2, 2), primes(2, 3)];
41 [[10007, 10009], [10007, 10009], [10007, 10009], [10009], [10009], [], [9973, 10007], [9973, 10007], [2], [2], [2, 3]]$
43 /* FACTORING TESTS */
45 ifactors(1);
46 [];
48 /* trial divisions */
49 ifactors(226800);
50 [[2,4],[3,4],[5,2],[7,1]];
52 /* limiting to factors */
53 ev( ifactors(226800), factors_only:true );
54 [2,3,5,7];
56 /* this is still found by trialdivision */
57 ifactors(5178997768267);
58 [[183823,1],[28173829,1]];
60 /* disable Pollard p-1 to test Pollard rho */
61 (save_pm1 : pollard_pm1_tests, pollard_pm1_tests : 0);
64 /* this should be found by Pollard rho */
65 ifactors(25091429338142886343);
66 [[3873703993, 1], [6477373951, 1]];
68 (pollard_pm1_tests : save_pm1, 0);
71 (save_prt : pollard_rho_tests, pollard_rho_tests : 0);
74 /* now this should be found by Pollard p-1 */
75 ifactors(25091429338142886343);
76 [[3873703993, 1], [6477373951, 1]];
78 (pollard_rho_tests : save_prt, 0);
81 /* disable Pollard rho and p-1 to test ECM */
82 (save_prt : pollard_rho_tests, pollard_rho_tests : 0);
85 (save_pm1 : pollard_pm1_tests, pollard_pm1_tests : 0);
88 /* now this should be found by ECM */
89 ifactors(25091429338142886343);
90 [[3873703993, 1], [6477373951, 1]];
92 (pollard_rho_tests : save_prt, 0);
95 (pollard_pm1_tests : save_pm1, 0);
98 /* MODULAR POWERS AND INVERSE */
100 power_mod(2^64,2,2^64-2^34+1);
101 240518168561;
103 inv_mod(42,2^64-2^34+1);
104 18007535864707547137;
106 /* negative exponents */
107 power_mod(3,-1,41);
110 inv_mod(3,41);
113 power_mod(2^64,-2,2^64-2^34+1);
114 18446743816011514066;
116 inv_mod(2^128,2^64-2^34+1);
117 18446743816011514066;
119 /* zero divisors */
120 inv_mod(3,42);
121 false;
123 power_mod(3,-1,42);
124 false;