Question
Climbing a Ladder Write a recursive function that will calculate the number of ways you can climb a ladder with n rungs. You can either
Climbing a Ladder
Write a recursive function that will calculate the number of ways you can climb a ladder with n rungs. You can either climb one rung, or two rungs at a time. The function must be recursive, no loops are allowed. Examples Input of 2 will return 2 because you can climb the ladder 1 rung + 1 rung or 2 rungs at once Input of 3 will return 3 because you can climb the ladder 1 rung + 1 rung + 1 rung, 1 rung + 2 rungs, or 2 rungs + 1 rung Input Do not read in input! There will be no input read in anymore. Going forward use the hard-coded input on the template and ensure the program works. There will be one compare output test based on the hard-coded input. The rest of the tests will be unit tests. Output Print the result from your function
use this function
#include
int climbLadder( int n ) { // There are a few base cases you can use. You know the number of ways to climb a ladder of n rungs when n is a small number. }
int main(){
int ladderSize = 25; // Call your function //Print the result
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started