EE-WEB Assignment 4

Program 1, 30pts.

Write a program in Java that would find the first prime numebr with more than 16 digits. Such large numebrs cannot be stored inside a regular data type. You will need to use BigInteger data type. Please refer to the BigInteger class descrition in the Java Documentation (either from Sun Web site or local download) and to the textbook factorial sample program that is discussed in Core Web Programming on page 317.

A prime number is a number that can be divided only by one and itself. The suggested approach is to start with 1000000000000001 and test this numeber by checking its reminder from division by 2, 3, 5, 7, ... until itself minus one, or better, until only its square root. If the reminder is nonzero for all tests it is a prime numeber - print it and stop the program. If at least one of the tests produces the reminder of zero, stop testing and increase the number by two to the next odd number.

Please make your program capable running on very large numbers but test it whether it weorks correctly using much smaller numbers like 101 or 1001 to start with. The main reason for this homework is to get you familiar with Java compilers and online language documentation.

Homework Submission

Attach all source code in files with proper names and extensions (*.html, *.java, *.pl, *.php, .htaccess e.t.c.). Do not ZIP files together or include compiled files (e.g. *.class). In case of dynamic Web pages (JavaScript or CGI) or Java applets also send the complete URL (including http://) that points to a page on your Web site that demonstrates your homework. Send your homework via e-mail to the instructor. Please set the message subject to: web-hw4.

Thank you.

web site front local main page local list page print this page   general bookmarks software bookmarks go back close this page copyright info   visitor counter