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
learn maths and leave the fear of it
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