| Follow the above link or click the graphic below to visit the Homepage. |
| Lucas & Perrin Probablisitic Prime Tests Jim Cullen |
| Lucas Probablistic Prime Test Function Code for TI-89/92/V200 Series Calculators |
|
:lucp(z) :Func : Local a,b,t :[[1,1][1,0]] \->\ a : z \->\ b : [[1,0][0,1]] \->\ t :Loop :If mod(b,2)=1 : mod(t*a,z) \->\ t :int(b/2) \->\ b :If b=0 : Exit :mod(a^2,z) \->\ a :EndLoop :if mod(2*t[2,2]+t[1,2],z)=1 : return true :return false :EndFunc |
lucp( 13 ) returns 'true'
lucp( 319 ) returns 'false' since ( 319 = 11 * 29 )
lucp( 651693055693681 ) returns 'false' in 5.37 sec
lucp( 705 ) returns 'true' though 705 is obviously NOT a prime number since ( 705 = 3 * 5 * 47 )
lucp( 2465 ) returns 'true' though again 2465 is NOT a prime number since ( 2465 = 5 * 17 * 29 ). These last two examples should be enough to demonstrate the fact that there are numbers that fool this test.
| Perrin Probablistic Prime Test Function Code for TI-89/92/V200 Series Calculators |
|
:perrp(z) :Func : Local a,b,t :[[0,1,1][1,0,0][0,1,0]] \->\ a : z-2 \->\b :[[1,0,0][0,1,0][0,0,1]] \->\ t :Loop :If mod(b,2)=1 : mod(t*a,z) \->\ t :(b-mod(b,2))/2 \->\ b :If b=0 : Exit :mod(a^2,z) \->\ a :EndLoop :if mod((t*[[2][0][3]])[1,1],z)=0 : return true :return false :EndFunc |
perrp( 41 ) returns 'true'
perrp( 93 ) returns 'false' ( 93 = 3 * 31 )
perrp( 651693055693681 ) returns 'false' in 9.11 sec so our example Carmichael Number didn't fool the Perrin test either. Notice that it took the Perrin test longer to run due to a larger matrix but the Perrin test is also more powerful.
perrp( 271441 ) returns 'true' in 3.00 sec
perrp( 904631 ) returns 'true' in 3.47 sec