Giter Club home page Giter Club logo

fibonacci's Introduction

Fibonacci

This is a demo application for providing a Fibonacci number at a given location. The application assumes a standard Fibonacci sequence [1, 1, 2, 3, 5, ...].

There are two methods used:

  1. Generation
    1. Generate a Fibonacci sequence of length n
    2. Return the Fibonacci number at location v
  2. Calculation
    1. Use a formula to calculate the Fibonacci number at location v (without generating the sequence).

How to run

Docker

The easiest way to run this program is via the Docker image.

docker run spncrgr/fibonacci help

This will pull the image from Docker Hub and print out it's usage:

Commands:
  fib calculate NUM   # Return the NUMth item in a standard Fibonacci sequence
  fib generate NUM    # generate a Fibonacci sequence and return the NUMth nu...
  fib help [COMMAND]  # Describe available commands or one specific command

Ruby

If you have Ruby installed on your system, you can also run the application directly by cloning this repo.

$ git clone https://github.com/spncrgr/fibonacci.git
$ cd fibonacci
$ ruby exe/fib help

This will print out the same usage instructions as with the Docker image.

Example Usage

Note: The examples provide the commands for running via Docker image or Ruby, respectively.

Generate a sequence of the first 10 Fibonacci numbers and return the value of the 10th number:
$ docker run spncrgr/fibonacci generate 10
# OR
$ ruby exe/fib generate 10

OUTPUT:

Generating a sequence of 10 Fibonacci number(s)...
The Fibonacci number at entry 10 is 55

Time:
       user     system      total        real
   0.000041   0.000003   0.000044 (  0.000012)
Calculate the value of the 10th number in a Fibonacci sequence:
$ docker run spncrgr/fibonacci calculate 10
# OR
$ ruby exe/fib calculate 10

OUTPUT:

The Fibonacci number at position 10 of a standard
sequence is 55

Time:
       user     system      total        real
   0.000166   0.000154   0.000320 (  0.000675)

fibonacci's People

Watchers

Spencer Roach avatar James Cloos 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.