Skip to content

CLI tool to run factorization, primality, and radical simplification functions

License

Notifications You must be signed in to change notification settings

al-ce/primecheck.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

primecheck.py

A CLI tool to check if any ints in a list are prime and print their factors, or to print all primes up to n.

out

Usage

Clone the repo, cd into the directory, and install with pip install . The cli command for the program is pprime (mnemonic for 'py-prime').

Prime-Check

Pass any number of ints as positional arguments and the program will print them back in color. All primes are green, all composites are red.

Screen Shot 2023-01-26 at 18 04 09

Unsorted

By default, the program sorts the list before it prints it back, but this can be overridden with the -U flag.

Screen Shot 2023-01-26 at 18 00 52

Grouped Factors

By default, the program will print out the sorted set of unique factors of any composite integer. When the -G flag is set, the factors will be grouped into their factor pairs.

Screen Shot 2023-01-27 at 02 04 42

Prime Factors

Setting the -P flag prints the prime factors of the integer rather than the composite factors.

Screen Shot 2023-01-27 at 02 08 37

Prime-List

Pass the -N flag followed by an int to print all primes up to that number.

list

Radical Simplification

Simplify any nth-root radical with -rs {nth} {base} by factoring out all perfect squares. The radical terms are formatted root{nth}{base}. For example, 3(root(3)(6)) is equivalent to 3 * ∛6

Screen Shot 2023-01-29 at 22 22 56

Testing Implementation

The program's Test class is intended to be used for testing with pytest. The two functions are checked against a list of the first ten-thousand primes as well as each other. To run the tests, clone the repo, cd into the directory, and run pytest in the terminal.

About

CLI tool to run factorization, primality, and radical simplification functions

Resources

License

Stars

Watchers

Forks

Languages