Solving The Staircase Problem With Just 5 Linesby@indepthjavascript

Solving The Staircase Problem With Just 5 Lines

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Staircase Programming Challenge: How many different ways can you reach the top of the stairs? How many ways you can take 1, 2, or 3 steps at a time? There is a simple way to solve this problem using everyone's favorite algorithm: **recursion. Here is the solution in 5 lines of JavaScript code: stepTaken is a counter for steps taken in each combination. It's tricky for sure, but once you understand it, it opens up a whole new world of possibilities!

Company Mentioned

Mention Thumbnail
featured image - Solving The Staircase Problem With Just 5 Lines
Amit Mehta HackerNoon profile picture

@indepthjavascript

Amit Mehta


Receive Stories from @indepthjavascript

react to story with heart
Amit Mehta HackerNoon profile picture
by Amit Mehta @indepthjavascript.Self taught full stack developer. Enjoys yoga & meditation. Lives with his wonderful wife and 2 cats in Abington, PA.
Read My Stories

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa