about | help | code help+videos | done | prefs |
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) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 270
Copyright Nick Parlante 2017 - privacy