So I am programming in BASIC Right now, And I just finished our assignment, but I'm confused as To why a slight variation in loop makes the program work.<br /><br />This is the working code:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Repeat<br />Â Â Â Â factors = 0<br />storage = Input("Enter a number ")<br />Â Â Â Â For counter = storage To 1 Step -1<br />Â Â Â Â Â Â Â Â If (storage Mod counter = 0)<br />Â Â Â Â Â Â Â Â Â Â Â Â factors = factors + 1<br />Â Â Â Â Â Â Â Â EndIf<br />Â Â Â Â Next<br />Until factors = 2<br />Print "Prime!"<!--c2--></div><!--ec2--><br />As you can tell, that is a program that waits until the user inputs a prime number. My curosity stems from the fact that my first attempt at this program didn't work. I used another Repeat...Until instead of a for loop, and it did not work. It was something like this:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><br />spy = 0<br />Repeat<br />Â Â Â Â factors = 0<br />storage = Input("Enter a number ")<br />Â Â Â Â Repeat<br />Â Â Â Â Â Â Â Â If (storage Mod counter = 0)<br />Â Â Â Â Â Â Â Â Â Â Â Â factors = factors + 1<br />Â Â Â Â Â Â Â Â EndIf<br />Â Â Â Â Â Â spy = spy + 1<br />Â Â Â Â Until (storage = spy)<br />Until factors = 2<br />Print "Prime!"<br /><!--c2--></div><!--ec2--> This code doesn't work, and I was wondering why? <br /><br />(Well actually I think my code was like that, I accidently deleted my original code so this is based off of my memory.) If I can't get an answer, it's okay, as I've already done it with a For loop anyways.<br /><br />I use the blitzbasic compiler. Thanks.<br /><br /><span class='edit'>This post has been edited by <b>Revitalized</b>: 25 Sep, 2007 - 11:00 AM</span>
</div>
</div>