GithubHelp home page GithubHelp logo

racca3141 / snap-push-pop Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5 KB

Recursion examples of 1, 2, 3 steps of n stair steps and a palindrome.

Java 100.00%
recursion 1-3-5 staircase palindrome stairs steps

snap-push-pop's Introduction

snap-push-pop

Recursion examples of 1, 2, 3 steps of n stair steps and a palindrome.

Stairs:

Objective -- "Create a class with a method that calls itself to calculate the number of ways a person could climb a staircase of n steps if they can take 1 step at a time, 3 steps at a time, 5 steps at a time, or any combination thereof. Allow the user to specify the number of steps n. Assume at the top of the stairs there is a flat surface so it doesn't matter if the user oversteps on their last step."

image

The table above calculates these combinations manually for 5 stair steps. Notice that order matters?

The answers follow a type of Fibonacci sequence:

a = (a - 1) + (a - 2) - 1

Palindrome:

The recursion works by taking the outer two characters that make the string and compares them. If that fails, then the method ends and says that the string is not a palindrome. If it passes, it sends the remaining string back into the method to do it again until the base cases are satisfied. The base cases of 0 and 1 string length are self explanatory.


This was created for College of the Sequoias' (Tulare, CA) COMP 008 - Programming Concepts.

snap-push-pop's People

Contributors

racca3141 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.