about | help | code help+videos | done | prefs |
Write a method that returns the total number of Xes that would appear in a 'num' high "stack". Stacks are made by placing one X on top of two Xes on top of three Xes, up to 'num' Xes. For example, if 'num' was 4, you would have a "stack" that looked like this: X XX XXX XXXX ...which has a total of 10 Xes, so you would return 10. This problem can be solved several ways. It is possible to solve using a loop, using recursion, or even without any looping or recursion! You have free choice of the method of solution. test2021_04_08_P1SLHL_countStacks(1) → 1 test2021_04_08_P1SLHL_countStacks(2) → 3 test2021_04_08_P1SLHL_countStacks(3) → 6 ...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