1. TI-83 Plus... Primes

Hey guys,

I heard some of the other TI calculators can check whether a number is prime, and if it's not, give the prime factorization for that number. I don't know more than that, I only know that my TI-83 Plus can't do it.

Is there a way I can program it to check to see whether a number is prime? Then, if not, give the factorization?

if that is too much for my old TI-83 (I know, I should get a new one...) is there a way I can just get it to list the first ~200 prime numbers? I know, I can calculate it out or look it up online, but it would be nice to have it at the push of a button!

What do you think?

(BTW I saw the other post in this forum that's kind of like my question, but I didn't want to hijack her thread and I'm ok with just a list of the numbers, if need be.)

2. Originally Posted by mander
Hey guys,

I heard some of the other TI calculators can check whether a number is prime, and if it's not, give the prime factorization for that number. I don't know more than that, I only know that my TI-83 Plus can't do it.

Is there a way I can program it to check to see whether a number is prime? Then, if not, give the factorization?

if that is too much for my old TI-83 (I know, I should get a new one...) is there a way I can just get it to list the first ~200 prime numbers? I know, I can calculate it out or look it up online, but it would be nice to have it at the push of a button!

What do you think?

(BTW I saw the other post in this forum that's kind of like my question, but I didn't want to hijack her thread and I'm ok with just a list of the numbers, if need be.)

Does this help?

--Chris

3. Ah well, I don't have a cable and it probably wouldn't arrive before the end of my class, so I'll just make do with memorization/calculation.
Thanks anyway!

4. I have a program which calculates the prime factors of a given number.

The output-screen are 2 lists (collected in a matrix) printed row-wise(?):

The first row contains the exponents which belong the the prime-factors, listed in the second row.

I've attached a screen shot how to use this program.

If you are interested I'll publish the program-listing which you have to type into your calculator.

Given number = 4862

Result: $2^1 \cdot 11^1 \cdot 13^1 \cdot 17^1$

5. Originally Posted by mander
Ah well, I don't have a cable and it probably wouldn't arrive before the end of my class, so I'll just make do with memorization/calculation.
Thanks anyway!
You could write a simple program to check a particular number by just iterating through each natural number less than or equal to the square root of the given number and checking to see whether the number divides the given number. Consult your manual for reference on program syntax.

Alternatively, if you want to calculate a list of primes by hand, a good method is the sieve of Eratosthenes. Write out a list of numbers from 2 to however high you want to go. Then do this: Cross off every multiple of two, but not 2 itself, in the list (i.e., cross out every second number after 2). Find the next number after two that isn't crossed out, in this case 3, and cross off every third number after 3 (e.g., 6, 9, 12, etc; some will already be crossed out). Continue this process over the whole list, and the numbers that remain that haven't been crossed off are prime.

I'll give an example for the primes less than 25:

Make the list:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Cross off (in this case they are marked in red) multiples of 2 (but not 2 itself):
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Cross off multiples of 3 (but not 3 itself):
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

The next unmarked number is 5, so cross off all multiples of 5 (but not 5 itself):

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

You would continue by crossing out multiples of 7, 11, 13, etc., but for our short list, all the remaining multiples are already crossed out. We are left with the prime numbers 2, 3, 5, 7, 11, 13, 17, 19, and 23. The process works the same way for a larger list.

Once you have the list, it would be easy to store it in your calculator for later access (and, in fact, a list of primes can easily be found just by searching the Internet).

6. Originally Posted by earboth
I have a program which calculates the prime factors of a given number.

The output-screen are 2 lists (collected in a matrix) printed row-wise(?):

The first row contains the exponents which belong the the prime-factors, listed in the second row.

I've attached a screen shot how to use this program.

If you are interested I'll publish the program-listing which you have to type into your calculator.

Given number = 4862

Result: $2^1 \cdot 11^1 \cdot 13^1 \cdot 17^1$
That would be very helpful, earboth - it looks like something that I could definitely use when I'm doing my work. I have never programmed a calculator before, but this might be a good lesson for that as well.

And thanks Reckoner - that method is similar to what I use. Your visual depiction of that process is pretty cool though. The problem is when I have to determine primes of a very large number (where the sqrt is also very large), which I can calculate on my own or I could look it up, but it would be handy to have my calculator do it to help save a little time. I can do it longhand, it's not a problem, but it's just the time. I'm going for speed on these problems!

7. Originally Posted by mander
That would be very helpful, earboth - it looks like something that I could definitely use when I'm doing my work. I have never programmed a calculator before, but this might be a good lesson for that as well.

...
Here comes the code:

PROGRAM:FACTOR
:ClrHome
:0→dim(L1)
:0→dim(L2)
:Input "NUMBER= ",Z
:1→N
:2→B
:0→E
:√(Z)→M
:While B≤M
:While fPart(Z/B)=0
:E+1→E
:Z/B→Z
:End
:If E>0
:Then
:B→L2(N)
:E→L1(N)
:N+1→N
:0→E
:√(Z)→M
:End
:If B=2
:Then
:3→B
:Else
:B+2→B
:End
:End
:If Z≠1
:Then
:Z→L2(N)
:1→L1(N)
:End
:If Z≠1
:Z→L2(N)
:1→L1(N)
:End
:List►matr(L1,L2,[A])
:Pause [A]T

If I were you I would print this listing.
The first steps:

PRGM --> NEW --> ENTER
Choose a name for the program. FACTOR isn't a bad choice

The double-points, indicating a new command, are inserted by the calculator when you press ENTER

You only have to use the ALPHA-key to write the variables and the word "NUMBER =". You must find all other expressions in the various menus of the TI83/84.

For instance: Never write [A] as 2ND x ALPHA MATH 2nd -
but use the matrix menue: 2nd x^-1 NAMES 1

8. Thanks Earboth!
Brilliant!

Sadly my calculator was stolen by a classmate the day I posted. So I will have to get another and try this again.

Very frustrating, but I can't wait to give this a go! Thanks!!

9. Code:
Do not enter semicolons(;) and/or the text that follows semicolons, they are notes for the user(you), that the TI-83 plus can't handle.

All commands, such as ClrHome, Dim, Input, If, Then, End, etc., etc. must be entered by a menu (e.g. MATH, PRGM, TEST).
E.g. is short for exempli gratia.
Exempli gratia is a Latin phrase which may be translated into English as "for the favor of example" or "for the sake of example."
E.g. should not be confused with id est.
Id est is also Latin.
Id est may be translated into English as "it is" or "that is."
The commands will not work if they are entered using the ALPHA state.

L1 and L2 are lists which must be entered by pressing the 2nd key followed by 1 or 2 respectively.
Respectively, in the previous sentence, means that 1 goes to L1 and 2 goes with L2, that they go together in the order presented.
Variables (e.g. Z, N, E, B, M) and String (e.g. "NUM:") may be entered using the ALPHA state and keys with the appropriate green character to their top right.

Matrix [A] must be entered using the matrix menu accessed by using 2nd shift key and the inverse key (5 keys above ON).

The =,≠,> and similar sings may be found in the TEST menu which is accessed by pressing 2nd and MATH (6 keys above ON).

All commands may be found in the CATALOG menu accessed by pressing 2nd and Zero(0) (one key to the right of ON).

PROGRAM:ProgramX	; Type of application: Name of application
:ClrHome
:0→dim(L1)	; set List1 to size 0, id est, clear list one. List1 stores the number of times each of NUM's prime factors goes into NUM.
:0→dim(L2)	; same but for List2. List2 stores the value of each of NUM's unique primes.
:Input "NUMBER= ",Z	; Say "NUM:" to ask the user for a number. Store the number in Z.
:1→N		; Store 1 in N, id est, set N to 1. N is the number of times B divides evenly into NUM. N is the number of NUM's unique primes.
:2→B		; Set B to two(2). Two(2) is the lowest prime number.
:0→E		; Set E to zero(0). E is the number of time B divides evenly into NUM. The exponent of the prime B.
:√(Z)→M		; set M to the square root of Z. M is the highest possible number that can divide Z if Z is not prime.
:While B≤M	; Run the program until B is greater than the square root of Z
:While fPart(Z/B)=0	; Divide Z by B as long as the division is "even", id est, there is no remainder(fPart is the fraction part which or remainder).
:E+1→E		; Add one to the tally of E every time B divides evenly into Z.
:Z/B→Z		; Every time B divides evenly into Z, store the result as the new Z.
:End		; End of the "While fPart(Z/B)=0" loop
:If E>0		; If Z was divisible for the current B,
:Then		; Then
:B→L2(N)	; Store the value of B in List 2 at position N
:E→L1(N)	; Store the value of E in List 1 at position N
:N+1→N		; Increase N by 1. The program will look for another prime.
:0→E		; Reset E to 0, because NUM might not be divisible by the next B.
:√(Z)→M		; Set M to the current Z (NUM divided by all the primes discovered up to this point)
:End		; End of "If E>0" Then...
:If B=2		; If B is two(2)
:Then		; Then
:3→B		; Set B to Three (there are no even primes above 2)
:Else		; Otherwise
:B+2→B		; Set B to the next higher odd number.
:End		; End of "If B=2" Then...Else...
:End		; End of "While B≤M" loop
:If Z≠1		; If Z is not one (id est, If Z is a prime number)
:Then		; Then
:Z→L2(N)	; Store the value of Z in List2 position N
:1→L1(N)	; Store the value of 1 in List2 position N
:Else		; Otherwise ( If Not Z≠1)
:If Z=1		; If Z=1 (this is a part of a check to see if NUM was 1
:Then		; Then
:If N=1		; If Z=1 and N=1, id est, Z was not prime and was not divided by a value greater than 1.
:Then		; Then
:Z→L2(N)	; Store Z in List 2 at position N.
:1→L1(N)	; Store 1 in List1 at position N.
:End		; End of "If Z=1" Then...
:End		; End of "If Z≠1" Then...Else...
:List►matr(L1,L2,[A])	; Combine List1 and List2 as rows in Matrix [A]
:Pause [A]	; Pause the program and display Matrix [A]

######################################################################################################
ProgramX is a derivative work (in the artistic rather than mathematical sense) of a program developed
in Austria by a group of students under the guidance of a teacher. The teacher posted the program on
www.mathhelpforum.com under the handle EarBoth at at 2138 GMT on 16 July 2008. EarBoth gave permission
to Søren Kyale to publish ProgramX under a Creative Commons (by-nc-sa) license. Søren Kyale added some
documentation and revisions.

ProgramX was published under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported
by Søren Kyale <soren.kyale(AT)gmail.com>
on 7 February 2009.