TPD Opitz-Consulting com wrote:
mycoffee wrote:
To check a number whether prime or not you should check with prime numbers only
So create a List to hold the prime numbers and add to it every time you find one. Then use the List to check the bigger numbers
Additionally you can stop checking when the next prime devider is bigger that the numbers half (which means that the result of the devision is less than two), eg: when checking <tt>23</tt> you will find the result of <tt>11</tt> beeing <tt>2.09...</tt>. The result of <tt>13</tt> is <tt>1.79...</tt>, so you don't need to check <tt>17</tt>.
bye
TT
Yes, but not a half, it is sqrt of the number. For example, when check number 101, you should check if it divisible to 2, 3, 5, 7 and that is it, since the next prime, 11, 11^2 > 101
Anyway, this is about Math, not about java and I think the forum is not to solve the homework problem :)