Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 17 Online
OpenStudy (anonymous):

how do you test for primality in java. and if the input is not prime how do you output the product

OpenStudy (anonymous):

Use the modulus (%) operator. If 0 the number is even, if not it is odd. Discard number if even (and not 0, depending on how you look at it), then for all odd numbers write a recursive method that breaks down the number into its factors

OpenStudy (anonymous):

http://bit.ly/14hhKHQ

OpenStudy (anonymous):

For primality there are many different sieves that allow one to find prime numbers up to a given number; you can just use trial division and see if any of these divide your given number.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!