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.

TI-Basic => TI-BASIC
Author Message
Bwyard

Newbie

Joined: 28 Apr 2009
Posts: 17

 Posted: 29 Oct 2009 12:49:55 pm    Post subject: i created this code to find factors of a number not rpime factors is there a more efficent way to do this. btw LF is list F. and it will work for negative numbers but it doesnt output the factors as negative. Code: ```abs(Ans→X {1→LF 1→N 1→L While N≤√X If fPart(X/N)=0 Then N→LF(L) 1+L→L X/N→LF(L) 1+L→L End 1+N→N End SortA(LF)```Last edited by Guest on 29 Oct 2009 12:52:25 pm; edited 1 time in total
calcdude84se

Member

Joined: 09 Aug 2009
Posts: 207

 Posted: 29 Oct 2009 03:55:17 pm    Post subject: Right now I cannot think of a way better than your simple one that is not complicated You can optimize your program in a number of ways. I can give pointers, but I recommend that you look at a site, such as TI-Basic Developer, to give general tips. A revised version is in the code box below (Ignore things after a ';', they are comments) Code: ```abs(Ans→X;You already had this, but as a general rule, don't use closing marks (",],},) ) at the end of an expression (right before a "→" or at the end of a line) 0→dim(LF;I needed to do this for my changes 1→N;Variable L is unnecessary, its use is covered by "dim(LF" For(N,1,√X;For( is better than While when it can be easily used If not(fPart(X/N;An expression "0=..." is the same as "not(..." Then N→LF(1+dim(LF;This is shorter than what you had before X/N→LF(1+dim(LF;Same here End End If not(fPart(√X;Prevent one factor from showing up twice if the number is a perfect square dim(LF)-1→dim(LF SortA(LF;No parentheses!``` That's about all the optimizations I can think of...
Bwyard

Newbie

Joined: 28 Apr 2009
Posts: 17

 Posted: 29 Oct 2009 04:11:59 pm    Post subject: ok thanks and btw i thought i had the code in there to prevent square roots form being duplicated but i guess not i think i deleted it on accidenta nd didnt replace it.
 Display posts from previous: All Posts Oldest FirstNewest First
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.

»
 Page 1 of 1 » All times are UTC - 5 Hours