id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > test2021_04_08_P1SLHL_countStacks
prev  |  next  |  chance

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)

public int test2021_04_08_P1SLHL_countStacks(int num) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 250

Copyright Nick Parlante 2017 - privacy