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

 

abraskin@mbusd.org problemset03 > sumABSkipC
prev  |  next  |  chance

Given three parameters, a, b and c, return the sum of the numbers between a and b (inclusive) skipping by c. (c will always be greater than 0) Note: a might be greater than, less than, or even equal to b! For example: sumABSkipC(1,5,1) would count from 1 to 5 by 1, counting 1, 2, 3, 4, 5, resulting in the sum 1+2+3+4+5=15. sumABSkipC(1,5,2) would count from 1 to 5 by 2, counting 1, 3, 5 resulting in the sum 1+3+5=9. sumABSkipC(9,-3,3) would count from 9 to -3 by 3, counting 9, 6, 3, 0, -3 resulting in the sum 9+6+3+0+-3=15.


sumABSkipC(1, 5, 1) → 15
sumABSkipC(3, 9, 2) → 24
sumABSkipC(5, 1, 1) → 15

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

public int sumABSkipC(int a, int b, int c) { }

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

Difficulty: 250 Post-solution available

Copyright Nick Parlante 2017 - privacy