<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 7, 2015, at 4:58 PM, Ray Fix via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div></blockquote><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""><div style="font-family: Helvetica; font-size: 12px;" class="">There is an improvement in that it forced us to avoid integer overflow by specifying the end game (although the heat death of the universe might happen first if you run this in a playground). &nbsp;Since j escapes the scope of it’s loop we couldn’t use a for statement variable. &nbsp;I think this is actually a good thing because it makes this wrinkle more apparent.</div><div style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></div></div></div></div></div></div></blockquote>You can use a for loop, you just have to use a flag to indicate whether the number was found to be non-prime, or a label. Label approach (since using a flag is obvious);</div><div><br class=""><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">candidate:&nbsp;<span style="color: rgb(195, 34, 117);" class="">for</span>&nbsp;i&nbsp;<span style="color: rgb(195, 34, 117);" class="">in</span>&nbsp;<span style="color: rgb(4, 53, 255);" class="">2</span>&nbsp;..&lt;&nbsp;<span style="color: rgb(4, 53, 255);" class="">Int.max</span>&nbsp;{</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;<span style="color: rgb(195, 34, 117);" class="">for</span>&nbsp;j&nbsp;<span style="color: rgb(195, 34, 117);" class="">in</span>&nbsp;<span style="color: rgb(4, 53, 255);" class="">2</span>&nbsp;..&lt; i {</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color: rgb(195, 34, 117);" class="">if</span>&nbsp;i % j ==&nbsp;<span style="color: rgb(4, 53, 255);" class="">0</span>&nbsp;{</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color: rgb(195, 34, 117);" class="">continue</span>&nbsp;candidate</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;}</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;}</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;<span style="color: rgb(61, 29, 129);" class="">print</span>(i)</div><div><span style="font-family: Menlo; font-size: 18px;" class="">}</span></div><div><br class=""></div><div>-DW</div></div></body></html>