Giter VIP home page Giter VIP logo

recursion-exercises's Introduction

Reacursive Exercise

  1. Write a function that takes in two numbers and recursively multiplies them together.

  2. Write a function that takes in a base and an exp and recursively computes base exp . You are not allowed to use the ** operator!

  3. Write a function using recursion to print numbers from n to 0.

  4. Write a function using recursion to print numbers from 0 to n (you just need to change one line in the program of problem 1).

  5. Write a function using recursion that takes in a string and returns a reversed copy of the string. The only string operation you are allowed to use is string concatenation.

  6. Write a function using recursion to check if a number n is prime (you have to check whether n is divisible by any number below n).

  7. Write a recursive function that takes in one argument n and computes F n , the n th value of the Fibonacci sequence. Recall that the Fibonacci sequence is defined by the relation

    F n = F n−1 + F n−2

    where F 0 = 0 and F 1 = 1

    Visit the Wikipedia page on the Fibonacci Number for more information if you’re still confused.

recursion-exercises's People

Contributors

dezzy12 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.