Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439

Computer Science Courses

Related sites

Introductory Programming In Java

HW 3

Homework 3

Prime Factorisation

It is an amazing fact that any integer not equal to zero has a unique factorization as product of primes. But finding this unique factorisation can take a very long time for large numbers. This principle is behind some important cryptographic algorithms such as the RSA algorithm.It is worthwhile to take a look at the following site to learn about prime factorisation. In particular, examples 1 and 2 of this sitedemonstrate an algorithm which you might like to use in coding this homework.

Your task for this homework exercise is to write a Java program that takes an integer as its command-line argument and prints out the complete prime factorisation of that integer, with the factors in ascending order. Your class must have at least one other method in addition to your main method. Your output needs to look similar to the example below.

You do not have to do any other data checking. In otherwords, you may assume that the user will type in a non-negative integer, and that it's OK if your program crashes if they type in something else. You also do not have to worry about your program working for very big integers; just use long variables rather than the BigInteger class as in Homework 2.

Here is a sample run of such a program. Try to format your output as much like this as possible:

> java Factors 1515 = 1 * 3 * 5> java Factors 20082008 = 1 * 2 * 2 * 2 * 251> java Factors 19998171999817 = 1 * 1999817(that's a prime number)

When you will have completed your Java program, test it on a few numbers until you are sure of its correctness. (Once again, don’t worry if your program gives bad results for very large integers.)

There are some excellent web sites which discuss cryptography and explain how prime factorisation is used. The "Art of the Problem" cryptography series looks pretty good: .

Further Programming Ideas

Fermat Little Theorem, Primality Tests and Carmichael Numbers

TO BE COMPLETED

You do not have to complete this part to get the maximum mark for this homework.

Assessment

You will get up to two marks, if you present a solution of at least oneof the above problems during the next week lab.

HW 3

 

Updated:  Sun 12 Jun 2016 17:27:37 AEST Responsible Officer:   JavaScript must be enabled to display this email address. Page Contact:  

+61 2 6125 5111
The Australian National University, Canberra
CRICOS Provider : 00120C       ABN : 52 234 063 906