AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

nado() (2.0)

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Tue Oct 30, 2007 2:09 am    Post subject: nado() (2.0) Reply with quote

Ok, as I was in Math Class today I was working some problems that had to do with some variables: n, a, and d. It was very annoying to have to work out all of the steps. So I made up a function for it. Via nado() (the variables of the function put together.)

Code:
nado(n, a, d, ByRef OutputVar)
{
   OutputVar := a+(n-1)*d
   }


Examples:

Code:
nado(5, 2, 3, Equation) ; 14

MsgBox,, Answer, %Equation%

nado(1567, 57, 78, Equation) ; 12205

MsgBox,, Answer, %Equation%


Post feedback, please.

Update: v2.0:

Thanks to engunneer, I now have a more responsible method of using this function:

Code:
nado(n, a, d)
{
   Return a+(n-1)*d
   }


Example:

Code:
MsgBox,, Answer, % nado(1,3,5) ; 3


Last edited by Trikster on Tue Oct 30, 2007 2:26 am; edited 2 times in total
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Tue Oct 30, 2007 2:19 am    Post subject: Reply with quote

a more "standard" way of doing this would be

Code:

nado(n, a, d)
{
   Return a+(n-1)*d
}


Code:

Equation := nado(1,3,5)

_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Tue Oct 30, 2007 2:20 am    Post subject: Reply with quote

I know of this method of well, whatever you call it. And I tried it earlier without any success with yours, or my own code used.

Edit: Never mind, I got it to work by changing the example to the following:

Code:
MsgBox,, Answer, % nado(1,3,5)
Thanks.
Back to top
View user's profile Send private message
steliyan



Joined: 20 Apr 2007
Posts: 31

PostPosted: Tue Oct 30, 2007 6:30 am    Post subject: Reply with quote

I guess you're talking about arithmetic progression?
Back to top
View user's profile Send private message
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Tue Oct 30, 2007 3:08 pm    Post subject: Reply with quote

I belive so, I'm in second block right now. I can find out in a sec.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group