Factoriser:   Prime numbers

  Introduction:   The prime factors of a positive integer (numbers that can be written without a fractional or decimal component) are the prime numbers that divide into that integer exactly, without leaving a remainder. The process of finding these numbers is called integer factorization, or prime factorization.
This program Factorizer was written by [Thomas Dickerson  and referenced by [navyfalcon].
Note: Click on "Factorizer" to download the original program, then "right click" to extract the files and "F10" to load on "VTI".
keypad

Outline:
  Line 1. Clear
  Line 2 - 8. Error Code
  First Pass
  Second Pass
  Third Pass
  Fourth Pass
  Fifth Pass
  Sixth Pass
    Examples
    Reference
    Reference Links
 
  Seventh Pass
  Eight Pass
  Ninth Pass
  Tenth Pass
  Eleventh Pass
  Twelveth Pass
  Thirteenth Pass
  Fourteenth Pass
  Fifthteenth Pass
  Sixteenth Pass

prgmFACTORISER

Line Command or Statement Comments
   1. ClrHome Clear Screen
   2. Disp "ENTER POSITIVE ","INTEGER 
   3. Prompt A  Enter number
   4. If fPart(A) or A<2 Error code
   5. Then    |
   6. Disp "COULD NOT FACTOR    |
   7. Return    |
   8. End End Error code
   9.  
 10. {1->L1 
 11. A->W 
 12. 2->X 
 13. While X ≤ √(W 
 14. If not(fPart(W/X) checks for (not fraction part) or no remainder.
 15. Then 
 16. augment({X}, L1->L1 
 17. W/X->W 
 18. 1->X 
 19. End 
 20. X+1->X 
 21. End 
 22. A/prod(L1->W number / product of all factors = 1
 23. If W≠1 
 24. augment({W}, L1->L1 
 25. dim(L1)-1->dim(L1 
 26. L1 Displays factors

Reference:

Program Execution

First pass:

Line:
    3. A= 525
  10. L1= {1}
  11. W= 525
  12. X= 2
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/2= 262.5 fPart= 0.5
     (condition= false)
  20. X+1= 2+1= 3
 

Second pass:

Line:
  10. L1= {1}
  11. W= 525
  12. X= 3
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/2= 175 fPart= 0.0
     (condition= false)
  15. Then
  16. augment({X},L1->L1 augment({3},L1-> {1} = {3 1}
  17. W/X->W 525/3 = 175
  18. 1->X
  20. X+1->X = 1+1= 2
 

Third pass:

Line:
  10. L1= {3 1}
  11. W= 175
  12. X= 2
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/2= 87.5 fPart= 0.5
     (condition= false)
  20. X+1= 2+1= 3
 

Fourth pass:

Line:
  10. L1= {3 1}
  11. W= 175
  12. X= 3
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/3= 58.33 fPart= 0.33
     (condition= false)
  20. X+1= 3+1= 4
 

Fifth pass:

Line:
  10. L1= {3 1}
  11. W= 175
  12. X= 4
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/4= 43.75 fPart= 0.75
     (condition= false)
  20. X+1= 4+1= 5
 

Sixth pass

Line:
  10. L1= {3 1}
  11. W= 175
  12.X= 5
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/5= 35 fPart= 0.0
     (condition= false)
  15. Then
  16. augment({X},L1->L1 augment({3},L1-> {3 1} = {5 3 1}
  17. W/X->W 175/5 = 35
  18. 1->X
  20. X+1->X = 1+1= 2
 

Seventh pass:

Line:
  10. L1= {5 3 1}
  11. W= 35
  12. X= 2
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/2= 17.5 fPart= 0.5
     (condition= false)
  20. X+1= 2+1= 3
 
Eighth pass:
Line:
  10. L1= {5 3 1}
  11. W= 35
  12. X= 3
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/3= 11.66 fPart= 0.66
     (condition= false)
  20. X+1= 3+1= 4
 

Ninth pass:

Line:
  10. L1= {5 3 1}
  11. W= 35
  12. X= 4
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  If notfPart(W/4= 8.75 fPart= 0.75
     (condition= false)
  20. X+1= 4+1= 5

Tenth pass:

Line:
  10. L1= {5 3 1}
  11. W= 35
  12. X= 5
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/5= 7 fPart= 0.0
     (condition= true)
  15. Then
  16. augment({X}, L1->L1    augment({5}, L1->{5 3 1} =
     {5 5 3 1}
  17. W/X->W 35/5 = 7
  18. 1->X
  20. X+1->X = 1+1= 2
 

Eleventh pass:

Line:
  10. L1= {5 5 3 1}
  11. W= 7
  12. X= 2
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/2= 3.5 fPart= 0.5
     (condition= false)
  20. X+1= 2+1= 3
 

Twelveth pass:

Line:
  10. L1= {5 5 3 1}
  11. W= 7
  12. X= 3
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/3= 2.33 fPart= 0.33
     (condition= false)
  20. X+1= 3+1= 4
 

Thirteenth pass:

Line:
  10. L1= {5 5 3 1}
  11. W= 7
  12. X= 4
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/4= 1.75 fPart= 0.75
     (condition= false)
  20. X+1= 4+1= 5
 

Fourteenth pass:

Line:
  10. L1= {5 5 3 1}
  11. W= 7
  12. X= 5
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/5= 1.4 fPart= 0.4
     (condition= false)
  20. X+1= 5+1= 6
 

Fifthteenth pass:

Line:
  10. L1= {5 5 3 1}
  11. W= 7
  12. X= 6
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/6= 1.16 fPart= 0.16
     (condition= false)
  20. X+1= 6+1= 7
 

Sixthteenth pass:

Line:
  10. L1= {5 5 3 1}
  11. W= 7
  12. X= 7
  13. While X ≤ √(W = 22.9128...
     (condition= true)
  14. If notfPart(W/7= 1 fPart= 0.0
     (condition= true)
  15. Then
  16. augment({X}, L1->L1    augment({7}, L1->{5 5 3 1} =
     {7 5 5 3 1}
  17. W/X->W 7/7 = 1
  18. 1->X
  20. X+1->X = 1+1= 2
  21. End
  22. A/prod(L1->W 525/(7*5*5*3)=525/525 = 1
  23. If W≠1
     (condition= false)
  24. augment({W},L1->L1
  25. dim(L1)-1->dim(L1 or dim(L1) = 5 or (7 5 5 3 1) -1 = 4 or (7 5 5 3)
  26. L1 = {7 5 5 3}
 

Reference

TI Basic Commands or Statements:

 

While (condition)

commands
End
command
Executes commands while condition is true
 

If condition

commandA
commands
If condition = 0 (false), skips commandA
 

If condition

:Then

commands
End
commands
Executes commands from Then to End if condition = 1(true).

fPart(value)

Returns the fractional part or
parts of a real or complex
number, expression, list, or matrix.
 

prod(list[,start,end])

Returns product of list
elements between start and end.
 

not(value)

Returns 0 if value is /= 0. value
can be a real number, expression, or list.
 

dim(listname)

Returns the dimension (number of elements) of listname.
dim({1, 3, 5, 7})      4
 

augment(listA,listB)

Returns a list, which is listB connected to the end of listA.