id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

recur_sumEvenNumbers


Given an integer "n", return the sum of all even numbers starting with 2 up to and including n. For example, if "n" is the number 10, you should do 2+4+6+8+10 which is 30. The given integer "sum" will always start at 0.


recur_sumEvenNumbers(10, 0) → 30
recur_sumEvenNumbers(1, 0) → 0
recur_sumEvenNumbers(2, 0) → 2

...Save, Compile, Run (ctrl-enter)

public int recur_sumEvenNumbers(int n, int sum) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy