Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
I just recieved my Ti-81 in the mail today. One of the first things I do with my calculators, is make a primes generator using this code:

Code:
ClrHome
Prompt N
For(A,1,N,2)
 For(B,3,A-1,2)
  If fPart(A/B)=0
  A->B
 End
If B=A
Disp A
End
Pause


But to my suprise, the For( loop isn't present in this model and neither is Prompt. I tried to do it with Lbl and Goto but it didn't work.
This is almost a ritual for me, and it would be nice if I could get some working code for this Historical Calculator.

Edit1: If this helps the Program menu is this:

Code:
CTL:
1:Lbl
2:Goto
3:If
4:IS>(
5:DS<(
6:Pause
7:End
8:Stop

I/O:
1:Disp
2:Input
3:DispHome
4:DispGraph
5:ClrHome

EXEC:
//this is just:
N:Prgm1-Ɵ
I don't know if this works, but here's a straightforward translation from reading the manual:
Code:
ClrHome
Input N
1→A
Lbl O
 2→B
 Goto E
 Lbl I
  If FPart (A/B)=0
   A→B
  B+1→B
  Lbl E
 IS>(B,A-1)
  Goto I
 If B=A
  Disp A
 A+1→A
IS>(A,N)
 Goto O
Pause

Edit: Fixed OOO.
I believe I made changes to the code that should make it usable on the TI 81, though I'm not sure because I don't have one myself. From what I understand you just wanted one that does the same thing but is made with labels and without using the prompt command, so here is one I made that seems to be working with only adding the input command (which I believe functions the same):

Code:
ClrHome
Input "N?-",N
~1->A
Lbl A
A+2->A
If (A>N)
Goto D
1->B
Lbl B
B+2->B
If (B>=A-1)
Goto C
If (fPart(A/B)=0)
A->B
Goto B
Lbl C
If (B=A)
Disp A
Goto A
Lbl D
Pause
jacobly wrote:
I don't know if this works, but here's a straightforward translation from reading the manual:
Code:
ClrHome
Input N
1→A
Lbl O
 3→B
 Lbl I
  If 0=FPart A/B:A→B
  B+1→B
 IS>(B,A-1):Goto I
 If B=A:Disp A
 A+1→A
IS>(A,N):Goto O
Pause

you can't type : on the Ti-81, but, I Tried it on the Ti-83+ I have and it didn't work anyway. I really do appreciate your help tho!

bdoggamer wrote:
I believe I made changes to the code that should make it usable on the TI 81, though I'm not sure because I don't have one myself. From what I understand you just wanted one that does the same thing but is made with labels and without using the prompt command, so here is one I made that seems to be working with only adding the input command (which I believe functions the same):


Code:
ClrHome
Input "N?-",N
~1->A
Lbl A
A+2->A
If (A>N)
Goto D
1->B
Lbl B
B+2->B
If (B>=A-1)
Goto C
If (fPart(A/B)=0)
A->B
Goto B
Lbl C
If (B=A)
Disp A
Goto A
Lbl D
Pause

This does work. I had to change the code to:

Code:
Input N
~1->A
Lbl A
A+2->A
If (A>N)
Goto D
1->B
Lbl B
B+2->B
If (B>=A-1)
Goto C
If (FPart (A/B)=0)
A->B
Goto B
Lbl C
If (B=A)
Disp A
Goto A
Lbl D
Pause

just some minor tweaks. It doesn't look like the

Code:
Input
command doesn't support two arguments, only one.

Code:
fPart(
used to be:
Code:
FPart
The TI-81's programming is very crude compared to that of the later models.

The 81 doesn't have :, so just start the next piece of code on the next line, which works exactly the same as having a : in the middle of the line.
jacobly wrote:
I don't know if this works, but here's a straightforward translation from reading the manual:
Code:
ClrHome
Input N
1→A
Lbl O
 3→B
 Lbl I
  If (FPart A/B)=0
   A→B
  B+1→B
 IS>(B,A-1)
  Goto I
 If B=A
  Disp A
 A+1→A
IS>(A,N)
 Goto O
Pause

Edit: Fixed OOO.

slight syntax thingy is wrong:

Code:

If (FPart A/B)=0

Should be

Code:

If (FPart (A/B))=0


I think this is because FPart on the Ti-81 Doesn't read operations unless told to do so

It does work when this is quickly fixed

Edit: This version of the code does not output primes before 5
jacobly, is there a way to fix this?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement