Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
i^N
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
i^N
Author Message
Galandros


Active Member


Joined: 29 Aug 2008
Posts: 565

Posted: 21 Apr 2010 08:04:19 am    Post subject:

The smallest code to calculate i^N where N is a integer number (positive or negative).
The answer has to be correct without rounding problems.

1st version:
you can not use round( command.

2nd version:
you cannot use "i^" and similar expressions.

Have fun! (I have a little cheating answer for the first and few idea for the second because I did not have complex numbers in class yet xD)


Last edited by Guest on 21 Apr 2010 01:53:04 pm; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 21 Apr 2010 09:21:15 am    Post subject:

[spoiler]
Code:
:{1,i,-1,-i
:Ans(1+N-4int(N/4
[/spoiler]

Last edited by Guest on 21 Apr 2010 10:46:24 am; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 21 Apr 2010 10:45:36 am    Post subject:

Version 1: 17 bytes (no program name)
Version 2: Having trouble getting it to where I'd like it... (The square root is exponentiation!)
Back to top
Galandros


Active Member


Joined: 29 Aug 2008
Posts: 565

Posted: 21 Apr 2010 02:09:39 pm    Post subject:

Good answer calcmaniac.
[spoiler]
Although I noticed the pattern, I did not remember to use a Look up List. *facepalm*
[/spoiler]

Weregoose wrote:

Version 1: 17 bytes (no program name)
Version 2: Having trouble getting it to where I'd like it... (The square root is exponentiation!)

I edited the rule to the original restriction I though hours before writing the topic...


Last edited by Guest on 21 Apr 2010 02:18:46 pm; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 21 Apr 2010 04:30:26 pm    Post subject:

Here goes:

[spoiler]17 bytes: e^(2[font=times new roman]πifPart(N/4

22 bytes: prod([font=times new roman]inot(0rand(4+4fPart(N/4[/spoiler]
Back to top
Galandros


Active Member


Joined: 29 Aug 2008
Posts: 565

Posted: 21 Apr 2010 04:48:34 pm    Post subject:

Answer for 1st teaser version.
[spoiler]
:i^(4fPart(N/4
I do not like the answer but it is valid. 8 bytes.
[/spoiler]

I knew Weregoose or thornahawk would appear with some math trick (talking about the first answer of Weregoose).
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 21 Apr 2010 05:26:47 pm    Post subject:

In counting bytes, I read the Mem Mgmt/Delů screen and then subtract the number of characters in the program name (prgmABC has three).

Both yours and mine have the same total.
Back to top
thornahawk
μολών λαβέ


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 22 Apr 2010 05:19:49 am    Post subject:

Isn't using e^( cheating as well, since ^ uses e^( internally anyway if the second argument is not an integer? ;)

Having said that, I would've taken calc84maniac's approach. ;)

thornahawk
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
i^N
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 

Advertisement