This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic Brain Teasers => TI-BASIC
Author Message
mr. sir


Newbie


Joined: 21 Feb 2008
Posts: 41

Posted: 18 May 2008 04:47:16 pm    Post subject:

My challenge for you today is to write a program to ask for the lower and upper bounds, then find and display, one at a time, all prime numbers within that range. My pathetic attempt was at about 249 bytes... Hopefully you can do better.
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 18 May 2008 05:29:23 pm    Post subject:

If you're going for size, this one is 43 bytes:
Spoiler wrote:
Prompt A,B
For(A,A,B
If min(1=gcd(A,seq(A,A,2,√(A
Disp A
End
The lower bound must be greater than three; the upper bound less than 1+106.

A probabilistic test might be better for assessing larger numbers quickly.


Last edited by Guest on 18 May 2008 05:36:09 pm; edited 1 time in total
Back to top
justusdude


Advanced Member


Joined: 24 May 2006
Posts: 265

Posted: 18 May 2008 06:04:58 pm    Post subject:

Here's mine.

Spoiler wrote:
Prompt N
For(A,1,N
Output(1,1,A
N/A->B
If fPart(B )=0
Then
For(C,2,A-1
If fPart(A/C)=0
Then
A->C
0->A
End
End
If A=/=0
Disp A
Pause
End
End
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 18 May 2008 06:08:13 pm    Post subject:

What number range would we be dealing with, here? Most interesting prime numbers are too big to fit entirely in a floating-point variable.
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 18 May 2008 06:27:45 pm    Post subject:

justusdude wrote:
Here's mine.
That outputs prime factors of the input. Check the first post again to see what is sought by the challenge.

Last edited by Guest on 18 May 2008 06:28:31 pm; edited 1 time in total
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement