To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 5022
5021  |  5023
Subject: 
Re: A recursion question/test...
Newsgroups: 
lugnet.robotics
Date: 
Wed, 12 May 1999 10:35:01 GMT
Original-From: 
Ben Laurie <ben@algroup.co*NoSpam*.uk>
Viewed: 
987 times
  
Jim Choate wrote:

Hi,

With all the discussion on understanding recursion and such for programmers
I thought I'd share a little problem I find enlightening....

Describe as simple a recursive algorithm as possible for summing the first n
numbers.

int sum(int n)
{ return n*(n-1)/2; }

A degenerate recursive algorithm, of course.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi
--
Did you check the web site first?: http://www.crynwr.com/lego-robotics



Message is in Reply To:
  A recursion question/test...
 
Hi, With all the discussion on understanding recursion and such for programmers I thought I'd share a little problem I find enlightening.... Describe as simple a recursive algorithm as possible for summing the first n numbers. ___...___ Three step (...) (26 years ago, 12-May-99, to lugnet.robotics)

7 Messages in This Thread:






Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
22 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR