GithubHelp home page GithubHelp logo

fibber's Introduction

Fibbonacci Sequence

The Fibbonacci sequence is a simple numeric sequence that comes up frequently in Computer Science and design tasks. Let's write a generator that can tell us an arbitrary quantity of numbers in the sequence.

##To Play

After you git clone the repository, cd fibber and type ruby fibber.rb and follow the prompts. Enjoy!

Theory

The sequence begins with the numbers 0 and 1. From there, each element is the sum of the previous two elements.

Start with 0 and 1
0 plus 1 is (1)
1 plus 1 is (2)
1 plus 2 is (3)
2 plus 3 is (5)
3 plus 5 is (8)
5 plus 8 is (13)
8 plus 13 is (21)

So the sequence starts 0, 1, 1, 2, 3, 5, 8, 13, 21.

Template

quantity = 15

# your code here

Challenge 1: Jagged Output

Output should come in rows of five elements. Running the program with quantity set to fifteen would output the following:

0 1 1 2 3
5 8 13 21 34
55 89 144 233 377

Challenge 2: Better Output

Our columns are kinda ugly. Let's pad each number into a four-character string so we get output like this:

   0    1    1    2    3
   5    8   13   21   34
  55   89  144  233  377

Challenge 3: Fancy Output

That works great until we want to output four-digit numbers in the sequence -- they'd start bumping into each other.

Can you output your sequence such that each element is padded to a string with a size one greater than the number of digits in the last element that will be output? So if the biggest number you'll output is three digits, each element of the sequence is padded to four places. But if the last element is four digits, each element is padded to five places.

fibber's People

Contributors

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