+ 1
I'll have to find the sum of first 25 integers using recurssion can anyone pl tell me how to do that ?
3 Réponses
+ 4
Hi! Please, show us your attempt. how far are you in solving this problem? what efforts have you already done for this?
+ 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.
+ 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) .....