Assignment 1

Due date: Wednesday September 22.


Second review assignment: write a program that prints the prime decomposition of an integer, that is to say list the prime factors of a number, with their multiplicity. For example:

60 = 2(2) * 3 * 5

128 = 2(7)

113 = 113

The input must be between 1 and 1000000. The format of the output is as given above, listing the prime factors in increasing order.

Start by building a table of prime numbers that is large enough. The program is interactive, and consists of a loop that queries the user for a new number and displays its factorization. Program terminates when input is zero.

You can write the program using dialog boxes, or else use System.in and System.out from a console window.

Optional: prettify the output so that instead of multiplicity in parenthesis, you display it as an exponent.