+ 1

I'll have to find the sum of first 25 integers using recurssion can anyone pl tell me how to do that ?

12th Sep 2022, 5:11 AM
SAIF ALI
SAIF ALI - avatar
3 Answers
+ 4
Hi! Please, show us your attempt. how far are you in solving this problem? what efforts have you already done for this?
12th Sep 2022, 5:53 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 4
Remember that recursion --has a stop case ... maybe if n is 0 -- has a step case ... to get the sum of 25 integers you might need to get the one of 24 integers and add them to 25.
12th Sep 2022, 6:35 AM
Oma Falk
Oma Falk - avatar
+ 4
a psudo code if you wish fun sum ( parameter : n ) if n <= 0 return 0 else return n + sum(n-1) this expands to n+sum(n-1) n+ n-1 + sum(n-1-1) n+n-1 + n-2 +sum(n-1-1-1) .....
12th Sep 2022, 6:41 AM
Prashanth Kumar
Prashanth Kumar - avatar