Giter Club home page Giter Club logo

primes-cli's Introduction

About Primes Cli

Primes CLI is a binary called primes, exposing a family of subcommands including primes near, primes between, which are all about finding small prime numbers in a certain range (0 to 18,446,744,073,709,551,615 on 64 bit machines, o to 4,294,967,295 on 32 bit). The basic mechanics leverage Sieve Of Eratosthenes and Prime Number Theorem, with optimisations to make it fast.

Value Proposition

It is occassionally useful to have a quick way to find a prime number near a particular value. I personally like to use prime numbers in cron-jobs, systemd timers, timeout settings, cache TTLs, and anywhere where there might be a risk of Thundering Herd Problem. It was mainly built for fun.

Primes

The command primes by itself does nothing useful, except produce the help screen (equivilant to primes help).

Primes Near

primes near takes one number as input and returns the nearest prime lower than that number, and the nearest prime higher. If the number you give it is itself prime, it returns 3 numbers

$ primes near 25            # returns 23,27
$ primes near 13            # returns 11,13,17
$ primes near banana        # exits with error: not a number

Primes Between

Takes two numbers (unsigned integers) and returns all the primes in that range, inclusive, so:

$ primes between 17 29      # returns 17,23,29

Primes Beneath

Goes all the way to the bottom, so:

$ primes beneath 25     # returns 2,3,5,7,11,13,17,19,23

Primes Is

Basic primality test:

$ primes is 50     # returns no
$ primes is 53     # returns yes

primes-cli's People

Contributors

sean9999 avatar

Stargazers

 avatar

Watchers

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