about | help | code help+videos | done | prefs |
Write a method that returns the sum of all the integers from 'low' up to and including 'high'. As preconditions you may assume that 'low' is less than or equal to 'high' and that the sum will not exceed the maximum value that can be stored in an integer. For example, if 'low' is -2 and 'high' is 4 you would return a 7 since (-2)+(-1)+(0)+(1)+(2)+(3)+(4) = 7. Look at the test data for other examples. test2023_11_02_APP1SLHL_sumFromTo(1, 500) → 125250 test2023_11_02_APP1SLHL_sumFromTo(7, 10) → 34 test2023_11_02_APP1SLHL_sumFromTo(43, 77) → 2100 ...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: 215
Copyright Nick Parlante 2017 - privacy