Skip to content

GeorgiosIoannouCoder/generate-and-test-prime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn GitHub

[Prime Number Checker] | Generate and Test Paradigm


Logo

Prime Number Checker

Prime Number Checker allows people to check if a particular positive integer from 3 to 100 inlusive is a prime numbers by uing the Generate and Test Paradigm.
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

Project Name Screen Shot

  • Prime Number Checker allows people to check if a particular positive integer from 3 to 100 inlusive is a prime numbers by uing the Generate and Test Paradigm.
  • Suppose you must determine whether a given number between 3 and 100, inclusive, is a prime.
  • Recall that an integer N≥2 is prime if its only factors are 1 and itself.
  • So 17 and 23 are prime whereas 33 is not, because it is the product of 3 and 11.
  • Assume that you must solve this problem without benefit of a computer or pocket calculator.
  • Your first attempt at a solution, using the generate-and-test approach, might look like the following pseudocode:
{While the problem is not yet solved and more possible factors for Number remain:
	[Generate a possible factor for Number
	/*possible factors will be generated in the
	order 2, 3, 4, 5, ...
	Number*/
	Test: If (Number) / (possible factor) is an integer >= 2 Then return not prime]
End While}
If possible factor equals Number, Then return Number is prime

Key Features

  1. This prime number checker uses the generate and test paradigm.
  2. The "generate and test" paradigm is a problem-solving approach used in computer science, artificial intelligence, and engineering. It involves the following steps:
    1. Generate: In this step, potential solutions are created or generated. This can involve coming up with various hypotheses, candidate solutions, or designs. In this case, generating possible factors.

    2. Test: Each generated solution is tested or evaluated to determine its effectiveness, correctness, or suitability. The testing process often involves assessing how well the solution meets the desired criteria or objectives. In this case, we check if the generated possible factor divides the original number.

    3. Iterate: Based on the test results, if a generated solution is not satisfactory, the process is repeated. New solutions are generated, tested, and the cycle continues until a satisfactory solution is found.

Back to top

Built With

Python JupyterNotebook

Back to top

Getting Started

To get a local copy of the Prime Number Checker up and running locally follow these simple example steps:

Prerequisites

NOTE: How to check if Python is installed and what is its version

  python --version

NOTE: How to check if Git is installed and what is its version

  git -v
  1. Please make sure you have pyenv installed and use any Python3 version:

  2. Please make sure you have git installed

Setup

  1. Navigate to the directory where you want to clone/run/save the application

    cd your_selected_directory
  2. Clone this repository

    git clone https://github.com/GeorgiosIoannouCoder/generate-and-test-prime.git
  3. Navigate to the generate-and-test-prime git repository

    cd generate-and-test-prime
  4. Use any Python3 version in the cloned repository folder:

    pyenv local 3.xx.xx
  5. Create virtual environment in the cloned repository folder

    python -m venv .generate-and-test-prime-venv
  6. Activate the virtual environment (Windows OR Mac/Linux):

    1. Windows
    .\.generate-and-test-prime-venv\Scripts\activate
    1. Mac/Linux
    source .generate-and-test-prime-venv/bin/activate
  7. Install ipykernel:

    pip install ipykernel
  8. Install Jupyter Notebook:

    pip install jupyter notebook
  9. Add the kernel of the virtual environment in the Jupyter Notebook:

ipython kernel install --user --name=.generate-and-test-prime-venv
  1. Run the Jupyter Notebook:
jupyter notebook
  1. Select the .generate-and-test-prime-venv kernel to run the Jupyter Notebook.

Back to top

Usage

  1. Define the lower (inclusive) and upper (not inclusive) bounds of the for loop in the last cell to check all the prime numbers in that specificed range. The range is initailly as [3, 100].

Back to top

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Back to top

License

Distributed under the MIT License. See LICENSE for more information.

MIT License

Copyright (c) 2023 Georgios Ioannou

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Back to top

Contact

Georgios Ioannou - @LinkedIn

Georgios Ioannou - @georgiosioannoucoder - Please contact me via the form in my portfolio.

Project Link: https://github.com/GeorgiosIoannouCoder/generate-and-test-prime

Back to top

About

This is my solution to the generate-and-test-prime to find out if a number is prime or not. ➗

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published