<br><br><div class="gmail_quote">On Sat, Mar 27, 2010 at 5:08 PM, yd <span dir="ltr">&lt;<a href="mailto:ydmt923@gmail.com">ydmt923@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>Having a problem finding the first 1000 prime numbers, here is my code:-<br><br>print(2)<br>n =3<br>counter =1<br>while counter &lt;=1000:<br>  for x in range(3,int((n**0.5)),2):<br>    if n%x != 0:<br>      print(n)<br>


      n+=1<br>      counter+=1<br>    else:<br>      n+=1<br>       <br>The problem is, it prints 2 and then does nothing, yet if i try and close,  it says program is still running do you want to kill it, is there a way to do this with lists, i know python has a prime function but i am not going to use it because i want to solve this problem without &#39;cheating&#39;.Thanks.<br>


<br>
<br></blockquote><div>What &#39;problem&#39; are you trying to solve?<br>In general, anytime you can use a premade solution, you are at an advantage, not cheating.<br>That&#39;s one of the marks of a truly good programmer - being able to reuse as much code as possible.<br>

Unless it&#39;s a homework problem and he said &quot;don&#39;t use the prime function&quot; because in this case, your goal is to learn how to write a prime function, not to calculate primes.<br>I.E. it&#39;s the doing, not the task.  And if that&#39;s the case, please let us know that it&#39;s homework.  We will still help you, we just follow certain guidelines<br>

when providing homework assistance so as not to &quot;give it away&quot; and still allow you to reason / come up with the solution on your own, as your teacher probably intended.<br><br>-Luke<br></div></div><br>