about | help | code help+videos | done | prefs |
sept26_2019_HL_strangeSum
Write a method that returns the "strange sum" of a non-negative integer parameter. The "strange sum" is the sum of the original number plus all of the numbers you get when you recursively divide the input parameter by 2 and call "strange sum" on that result. For example, the "strange sum" of 20 is 38 because 20+10+5+2+1=38. The 10 came from integer-dividing 20 by 2. The 5 came from 10/2. The 2 came from 5/2. The 1 came from 2/2. Look at the test data for further examples. Your solution MUST be recursive. sept26_2019_HL_strangeSum(0) → 0 sept26_2019_HL_strangeSum(1) → 1 sept26_2019_HL_strangeSum(2) → 3 ...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: 490
Copyright Nick Parlante 2017 - privacy