Skip to content

Print a multiplication table of prime numbers using the sieve of Eratosthenes

License

Notifications You must be signed in to change notification settings

MicahElliott/primetab

Repository files navigation

primetab

CircleCI codecov

Print a multiplication table of prime numbers using the Sieve of Eratosthenes (see a nice visual demo there).

Usage

Git this repo:

% git clone git@github.com:MicahElliott/primetab
% cd primetab

Build:

% lein uberjar

There is a tiny wrapper script provided. Run with:

% ./primetab [options]

Options

Run primetab --help to see the full list of options.

The basic configurables are:

  • the number of primes to print for the table
  • color or bland output
  • raw format to omit labels/headers for the table
  • csv or tsv delimiters

Examples

Print a small 5x5 table, blandly without color, in CSV format.

% ./primetab -n5 -bc

More documentation

Generate HTML docs:

% lein codox

See the generated codox HTML in target/default/doc/index.html

% $BROWSER target/default/doc/index.html

Development

There is no CI or real quality control yet. :) This code relies on kibit, joker, etc to keep code clean.

Testing

You can run the suite of unit tests with:

% lein test

To also run integration tests, run:

% lein test :all

In order to test "large" primes, you may need to set JVM options (i.e., initial memory allocation pool), like:

% JVM_OPTS='-Xss1g' lein test :all

I see ~500 MB being allocated to run the integration tests.

During development, it's handy to run unit tests constantly upon changes:

% lein auto test

Code quality

There are configured setups for ensuring code quality:

CodeClimate does not treat Clojure as a first-class citizen, but they support some basic checks, like lein kibit.

TODO (maybe)

  • Expand on tests for boundaries, long-running, overflows, etc
  • Add some specs
  • Add reloaded repl workflow via Component

License

Copyright © 2019 Micah Elliott / FC

About

Print a multiplication table of prime numbers using the sieve of Eratosthenes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published