Code Monkey home page Code Monkey logo

nacho-fibre's Introduction

Nacho Fibre

Setup

  • Fork the repo
  • Clone the repo

Description

You have two problems below. You should write psuedocode and code for each solution. Test cases are included to ensure proper functionality. You can run npm test in the terminal to run the test suite.

Problem 1: The Fibonacci Sequence

The Fibonacci sequence appears in nature all around us, in the arrangement of seeds in a sunflower and the spiral of a nautilus for example.

The Fibonacci sequence begins with fibonacci(0) = 0 and fibonacci(1) = 1 as its first and second terms. After these first two elements, each subsequent element is equal to the sum of the previous two elements.

Programmatically:

  • fibonacci(0) = 0
  • fibonacci(1) = 1
  • fibonacci(n) = fibonacci(n-1) + fibonacci(n-2)

Given n, return the nth number in the sequence.


Example

Input: 6

Output: 8

Explanation: The first 6 numbers (starting at index 0) in the fibonacci sequence are [0, 1, 1, 2, 3, 5, 8] so the 6th number is 8.


Problem 2: The Kaleb Sequence

The Kaleb sequence appears nowhere in nature and exists purely in this question.

The Kaleb sequence begins with kaleb(0) = 2 and kaleb(1) = -1 as its first and second terms. After these first two elements, each subsequent element is equal to twice the previous previous term minus the previous term.

Programmatically:

  • kaleb(0) = 2
  • kaleb(1) = -1
  • kaleb(n) = 2*kaleb(n-2) - kaleb(n-1)

Given n, return the nth number in the sequence.


Example

Input: 6

Output: 65

TODO

Explanation: The first 6 numbers (starting at index 0) in the kaleb sequence are [2, -1, 5, -7, 17, -31, 65] so the 6th number is 65.


Submission

  • Push your code
  • Create a Pull Request

nacho-fibre's People

Contributors

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