Program that compute prime numbers, JAVA Programming

Assignment Help:

The purpose of this assignment is to give you practice working with one dimensional arrays. It will also introduce you to one of the oldest mathematical algorithms in the world. Note: It's easy to find Java code for this algorithm on the Internet, but DON'T go looking for it. This is a simple algorithm. You are capable of implementing it yourself, and the purpose of the assignment is for you to do some programming. Feel free to look at the Wikipedia page on the Sieve of Eratosthenes, though.

Instructions:

1.  Write a program that will compute all of the prime numbers up to a specified value in a number of different ways.

  • Your program must have 3 command line arguments. The first gives that value that you want to generate primes to. The second gives the method that the program will use to generate the list of primes. The third argument, if present, tells the program to print out the list of primes, for debug purposes. For example, running the program as follows:

>Primes 100 1 p

should generate an array of numbers such that the elements with prime indices have value 1, and elements with composite indices have value 0. Since there is a 3rd command line argument, the program should print out the list of prime numbers.

2.        

  • The methods that you must implement are:

1. Trial division by the numbers up to n

2. Trial division by 2 and the odd numbers up to sqrt(n)

3. Trial division by the primes up to sqrt(n)

4. The sieve or Eratosthenes

Once it has finished, the program should also print out the amount of time that it took to run.

  • Run your program on different sized inputs for the different methods.
  • Write a 1 page report including a table or graph of the results.
  • Turn in your report, your code and class files to the D2L dropbox.

Optional: Optimize your sieve routine so that it uses an array of bits, and only stores the odd numbers in the array. See how high you can go with this optimized sieve. Write about it in your report.

Assignment checklist:

  • Write your program so that it works with command line arguments.
  • Write the 4 different prime finding modes.
  • Make sure the programs compile and run from the command line without modification.
  • Write a 1 page report summarizing the results of running your program in different modes, and for different list sizes.
  • Include your source, executable files and report in your turnin.
  • Zip all of your files in a SINGLE .zip file and turn it in to the D2L dropbox.

Related Discussions:- Program that compute prime numbers

War file for your application that can be deployed on tomcat, Deliverable: ...

Deliverable:  1) WAR file for your application that can be deployed and run on TomcaT (War file must contains the Java source code) Requirement for application: 1. Application m

Write a java adb client, Write a Java ADB client to perform the following- ...

Write a Java ADB client to perform the following- The client will read the contents of the file - invoice.txt. The first line of the file will display the type of the currency. The

When should i use abstract classes and interfaces, When should I use abstra...

When should I use abstract classes and when should I use interfaces?  Use Interface, when: Design changing often or when various implementations only share method sign

Program to read a keyboard value and exit from the code, Using the above t...

Using the above thread program, now create 20 threads in your program and run them. No need to wait for the keyboard in each thread, just print "Hello" and its thread id in each t

What is a portal?, A portal is a service or a Web site that gives broad ran...

A portal is a service or a Web site that gives broad range of services and resources like e-mail, forums, search engines, weather information, news, on-line shopping, stock quotes.

I want fitlife app for android - ios, I want FitLIFE app for Android, IOS, ...

I want FitLIFE app for Android, IOS, Windows Project Description: Hello, I want to develop an app for Android, IOS and Windows Phone. This app will be work with open source B

Java assignment, Java Project Introduction: In this project, you will ex...

Java Project Introduction: In this project, you will explore a few sorting algorithms. You will also test their efficiency by both timing how long a given sorting operation take

Need java, Need JAVA,SPRING,JSF(primefaces) Application Support Project ...

Need JAVA,SPRING,JSF(primefaces) Application Support Project Description: We want someone to be part of our team's new development, it's minute application but in future, cha

Javacard, I want to know if you can help me with a javacard programming pro...

I want to know if you can help me with a javacard programming project

Demonstrate a minimal server and client program, This exercise will give yo...

This exercise will give you some introductory exposure to network programming with sockets. Your task is to demonstrate a minimal server program and client program that can send on

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd