AutoHotkey Community

It is currently May 26th, 2012, 11:19 am

All times are UTC [ DST ]




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
PostPosted: November 3rd, 2008, 3:34 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
Moderator note: author requested topic lock.

Outputs the nth square number:

Code:
1   => 4
2   => 9
3   => 16
; ...
100 => 10000
101 => 10201
102 => 10609


Code:
Square(n) {
   Return n = 1 ? 4 : Square(n-1)+(3+(n-1)*2)
}


Seems to want to crash with any number higher than 287 on my comp.

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2008, 3:52 pm 
Offline

Joined: July 21st, 2006, 12:26 am
Posts: 223
n=0 should be retrieved -> 0^2 = 0

I don't think this is useful..

_________________
                                  [ profile | ahk.net | ahk.talk ]


Last edited by k3ph on November 3rd, 2008, 3:57 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 3rd, 2008, 3:52 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Trikster wrote:
1 => 4
2 => 9
3 => 16
That doesn't look right. Have you tried sq := n ** 2

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 8 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group