about | help | code help+videos | done | prefs |
Write a method that returns the "funny sum" of an array of integers. The funny sum is equal to the sum of all the numbers in the array, but some of the numbers are added multiple times. For example, given {5,7,2,3}, the "funny sum" is equal to 5+7+2+3 + 7+2+3 + 2+3 + 3 = 37. So each number is added once, then each number except the first number is added again, each time leaving out one more number. This can be done nicely with nested loops, but it also can be done with a single loop if you think about it first! Look at the test data for other examples. quiz2022_03_01_APSLHL_funnySum([]) → 0 quiz2022_03_01_APSLHL_funnySum([17]) → 17 quiz2022_03_01_APSLHL_funnySum([-4, -10]) → -24 ...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: 250
Copyright Nick Parlante 2017 - privacy