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

 

jebbert@volusia.k12.fl.us > ccc1SumProduct
prev  |  next  |  chance

Write a method that finds the sum of all the products of consecutive pairs of integers from 'first' to 'last'. For example, if first=4 and last=6 the method returns 50 because 4*5 + 5*6 = 50. Note that either parameter can be negative. Also you may assume first<last will always be true. Look at the test data for additional examples. Do not worry about getting a sum greater than the maximum possible integer value as none of the test data will cause that to happen.


ccc1SumProduct(1, 50) → 41650
ccc1SumProduct(-5, -2) → 38
ccc1SumProduct(-10, 10) → 660

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

public int ccc1SumProduct(int first, int last) { }

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: 270

Copyright Nick Parlante 2017 - privacy