anonymous
  • anonymous
how do you test for primality in java. and if the input is not prime how do you output the product
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • 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
anonymous
  • anonymous
http://bit.ly/14hhKHQ
anonymous
  • 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.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
http://en.wikipedia.org/wiki/Primality_test#Naive_methods

Looking for something else?

Not the answer you are looking for? Search for more explanations.