Answer to Question #3372 in Python for mukunda

Question #3372
Write Program to print sum of n even numbers in recursive method
1
Expert's answer
2011-08-02T14:00:50-0400
def sum_even_numbers (n):
if n == 0: return 0
return 2 * n + sum_even_numbers(n-1)

print(sum_even_numbers(7))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS