Giter Site home page Giter Site logo

threaded-is-prime's Introduction

threaded-is-prime

A multi-threaded java application that determines whether a number is prime.

Approach

Given a number n and the number of threads t, the values 2 to sqrt(n) are divided evenly into t parts. These parts are processed by multiple threads to check if the number n is a prime number.

Sample output

How many threads do you wish to create? 4

Created thread #1.
Created thread #2.
Created thread #3.
Created thread #4.

Is 32416190071 a prime number? true
Execution Time: 36 ms

Installation

Please note that this is an eclipse project. To import it on Eclipse:

  1. Clone this repository by typing git clone https://github.com/darrensapalo/threaded-is-prime.git on the terminal.
  2. Open Eclipse.
  3. Go to File > Import > General .. Existing Projects into Workspace > Select root directory .. browse.
  4. Select the directory where you cloned the repository. Click finish.
  5. Go to the class named PrimeChecker and configure the values as you need them.

Configuration

You can allow the user to either input a number via the system input stream, or you can automatically use a pre-selected prime number. To change this behavior, change this line:

/**
  * Determines whether the user will be asked for an input value.
  */
public static final boolean willGetUserInput = false;
	
/**
  * if <i>willGetUserInput</i> is false, then it will use this value for processing instead.
  */
public static final String defaultValue = Large;

Preselected prime numbers

Conveniently, we provide a small list of prime numbers you can use. To change which default value to use, modify the assignment to the defaultValue static attribute.

public static final String Small   = "472882049";
public static final String Medium  = "27704267971";
public static final String Large   = "32416190071";
public static final String XLarge  = "48112959837082048697";
public static final String XXLarge = "2074722246773485207821695222107608587480996474721117292752992589912196684750549658310084416732550077";

threaded-is-prime's People

Contributors

darrensapalo avatar

Stargazers

 avatar  avatar

Watchers

 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.