about | help | code help+videos | done | prefs |
Write a method that finds the "sum product" between two integer values, x and y, where y>x. The "sum product" is found by alternatively adding then multiplying or multiplying then adding, depending on the value of addFirst. If addFirst is true, then you start by adding, otherwise you start by multiplying. For example, with the parameters (5, 9, true) you would return the result by performing the following calculations: 5+6=11, 11*7=77, 77+8=85, 85*9=765, so you would return 765. However, with the parameters (5, 9, false) you would return the result of these calculations: 5*6=30, 30+7=37, 37*8=296, 296+9=305, so you would return 305. ddd1SumProduct(1, 3, true) → 9 ddd1SumProduct(-3, 3, true) → 21 ddd1SumProduct(-3, 3, false) → 5 ...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: 280
Copyright Nick Parlante 2017 - privacy