Question-79

Question-79

Give a recursive algorithm for finding the sum of the first n positive integers.

 

Solution

procedure sum of first (n : positive integer)

if  n = 1

then return 1

else  return sum of first (n – 1) + n

 

Leave a Reply

Your email address will not be published. Required fields are marked *