Skip to content

A command-line program written in ruby to be able to generate the multiplication table of any number of prime numbers

License

Notifications You must be signed in to change notification settings

coleby210/prime-multiplication-table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prime Multiplication Table

A command-line program written in ruby to be able to generate the multiplication table of any number of prime numbers

Table of Contents

Installation

These Instructions assume that you already have Ruby and the Bundler Gem installed.

Alright, lets get started!

First you need to clone the repository to a folder of your choosing. I'm going to use my Desktop.

$ cd ~/Desktop
$ git clone https://github.com/coleby210/prime-multiplication-table.git
# Cloning into 'prime-multiplication-table'...
# ...
# Checking connectivity... done.

Next we need to jump into the folder we just cloned:

$ cd prime-multiplication-table

Now we need to install all of the dependencies:

$ bundle install
# Using coderay 1.1.1
# ...
# Use `bundle show [gemname]` to see where a bundled gem is installed.

Woo! The programs installed!

Usage

First we need to jump into our program folder using the Terminal. So this depends on where you installed the program, if you followed my installation this will work: Note: If you just finished installing dependencies, you can skip this step as you're already in the folder.

$ cd ~/Desktop/prime-multiplication-table

Now we can properly run the program.

To use the default table of 10x10 primes:

$ ruby runner.rb
# +----+----+----+-----+-----+-----+-----+-----+-----+-----+-----+
# |    | 2  | 3  | 5   | 7   | 11  | 13  | 17  | 19  | 23  | 29  |
# | 2  | 4  | 6  | 10  | 14  | 22  | 26  | 34  | 38  | 46  | 58  |
# | 3  | 6  | 9  | 15  | 21  | 33  | 39  | 51  | 57  | 69  | 87  |
# | 5  | 10 | 15 | 25  | 35  | 55  | 65  | 85  | 95  | 115 | 145 |
# | 7  | 14 | 21 | 35  | 49  | 77  | 91  | 119 | 133 | 161 | 203 |
# | 11 | 22 | 33 | 55  | 77  | 121 | 143 | 187 | 209 | 253 | 319 |
# | 13 | 26 | 39 | 65  | 91  | 143 | 169 | 221 | 247 | 299 | 377 |
# | 17 | 34 | 51 | 85  | 119 | 187 | 221 | 289 | 323 | 391 | 493 |
# | 19 | 38 | 57 | 95  | 133 | 209 | 247 | 323 | 361 | 437 | 551 |
# | 23 | 46 | 69 | 115 | 161 | 253 | 299 | 391 | 437 | 529 | 667 |
# | 29 | 58 | 87 | 145 | 203 | 319 | 377 | 493 | 551 | 667 | 841 |
# +----+----+----+-----+-----+-----+-----+-----+-----+-----+-----+

To set the amount of primes to use a custom number, use -s:

$ ruby runner.rb -s 3
# +---+----+----+----+
# |   | 2  | 3  | 5  |
# | 2 | 4  | 6  | 10 |
# | 3 | 6  | 9  | 15 |
# | 5 | 10 | 15 | 25 |
# +---+----+----+----+

If you want assistance through the Terminal:

$ ruby runner.rb -h
# Welcome to the Primes Multiplication Table Help Menu!
# Use '-s' to set the amount of primes
# Example: ruby runner.rb -s 15

Testing

Open your Terminal and navigate to the project folder, I put mine on my desktop.

$ cd ~/Desktop/prime-multiplication-table

Run the testing suite:

$ rspec
# Interface
#  displays a help menu
#  can output a custom size primes table
#  outputs the default table of 10x10 primes

# String
#  has a new method to test if a string is actually an integer

# MultiplicationTable
#  is a Multiplication Table Object
#  can transform a prime multiplication table to a matrix
#  can transform any set of numbers in an array to a matrix

# Prime
#  checks if a number is prime
#  generates any number of primes
#  generates 10 primes by default

User Stories

  • I want to be able to print out to console a multiplication table of the first n primes
  • I want n to default to 10
  • I want the primes to be the x and y of the table
  • The program needs to be fully tested
  • I want all dependencies to be specified
  • The program needs to be deployed to github with clear documentation
  • The code needs to be fast and scalable

Built With

License

This program is licensed under the MIT License

About

A command-line program written in ruby to be able to generate the multiplication table of any number of prime numbers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages