Prime Factors For the TI-81 and TI-82
The original Prime Factor Analysis program appeared in the owner's manual for the Casio
fx-8000G graphic calculator. The program has been converted for use on the Texas Instrument
brand of calculators.
Prime Factors accepts any positive integer as input. It then produces all of the prime factors
(whole numbers that can only be evenly divided by one and itself), lowest value first.
Prgm:PRIME
:Input A
1. :~1\->\\th\
:If A>0
:Goto 2
2. :If A=0
3. :End
4. :~A\->\A
:Disp \th\
:Pause
:Goto 2
:Lbl 1
:Disp \th\
:Pause
:A/2\->\A
:If A=1
5. :End
:Lbl 2
:2\->\\th\
6. :If FPart(A/2)=0
:Goto 1
:3\->\B
:Lbl 3
7. :\sr\A+1\->\C
:Lbl 4
:If B\>=\C
:Goto 8
8. :If FPart(A/B)=0
:Goto 6
:Lbl 5
9. :B+2\->\B
:Goto 4
:Lbl 6
:Disp B
:Pause
:A/B\->\A
:Goto 3
:Lbl 8
:Disp A
10. :End
Instructions
Prime Factors expects the user to input a positive integer number. If the user accidently
enters zero, the program aborts. Fornegative entries, Factors converts the number into a
positive number and displays -1. The program considers fractionalanswers as prime; hence only
one prime number is displayed--the input itself. Factors pauses after each number is displayed.
Programming Notes
1.The TI-81 (not the 82's) cannot display constants right-justified. Instead, the constants
are stored in a dummy variable (in this case, theta) and later displayed correctly.
2.Tests for inputs of zero. If so, quit.
3.TI-82 Users: Change the End command to Stop.
4.The input is found to be negative by process of elimination. Changes input from negative
to positive.
5.TI-82 Users: Change the End command to Stop.
6.If the number is even, divide it by two and display 2.
7.Solves the quadratic and displays results.
8.Defines the upper limit of checking as one more than the square root of the number. For
example, the number 105 could not have a prime factor greater than 11, because any number
above would require a corresponding prime factor below 11.
9.If a prime factor is found, then display it and divide the number by the factor.
10.Increments the current checking number by two.
11.TI-82 Users: Change the End command to Stop.