Eliminate spurious redefinition of derivabbrev in Ctensor, fix documentation of diagm...
[maxima/cygwin.git] / tests / rtestifactor.mac
blobeb941bbe5fe88c4d3cd67481d3391e6766ff7f62
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 are checkd 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 /* FACTORING TESTS */
41 ifactors(1);
42 [];
44 /* trial divisions */
45 ifactors(226800);
46 [[2,4],[3,4],[5,2],[7,1]];
48 /* limiting to factors */
49 ev( ifactors(226800), factors_only:true );
50 [2,3,5,7];
52 /* this should be found by Pollard rho */
53 ifactors(5178997768267);
54 [[183823,1],[28173829,1]];
56 /* disable Pollard rho to test ECM */
57 (save_prt : pollard_rho_tests, pollard_rho_tests : 0);
60 /* this should be found by ECM */
61 ifactors(5178997768267);
62 [[183823,1],[28173829,1]];
64 (pollard_rho_tests : save_prt, 0);
67 /* MODULAR POWERS AND INVERSE */
69 power_mod(2^64,2,2^64-2^34+1);
70 240518168561;
72 inv_mod(42,2^64-2^34+1);
73 18007535864707547137;
75 /* negative exponents */
76 power_mod(3,-1,41);
77 14;
79 inv_mod(3,41);
80 14;
82 power_mod(2^64,-2,2^64-2^34+1);
83 18446743816011514066;
85 inv_mod(2^128,2^64-2^34+1);
86 18446743816011514066;
88 /* zero divisors */
89 inv_mod(3,42);
90 false;
92 power_mod(3,-1,42);
93 false;