Write a recursive method called waysToClimb that takes a positive integer value representing a number of stairs
Question:
Write a recursive method called waysToClimb that takes a positive integer value representing a number of stairs and prints each unique way to climb a staircase of that height, taking strides of one or two stairs at a time. Do not use any loops. Output each way to climb the stairs on its own line, using a 1 to indicate a small stride of 1 stair, and a 2 to indicate a large stride of 2 stairs. The order in which you output the possible ways to climb the stairs is not important, so long as you list the right overall set of ways. For example, the call waysToClimb(3); should produce the following output:
[1, 1, 1]
[1, 2]
[2, 1]
The call waysToClimb(4) ; should produce the following output:
[1, 1, 1, 1]
[1, 1, 2]
[1, 2, 1]
[2, 1, 1]
[2, 2]
Step by Step Answer:
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp