<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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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). Since j escapes the scope of it’s loop we couldn’t use a for statement variable. 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: <span style="color: rgb(195, 34, 117);" class="">for</span> i <span style="color: rgb(195, 34, 117);" class="">in</span> <span style="color: rgb(4, 53, 255);" class="">2</span> ..< <span style="color: rgb(4, 53, 255);" class="">Int.max</span> {</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(195, 34, 117);" class="">for</span> j <span style="color: rgb(195, 34, 117);" class="">in</span> <span style="color: rgb(4, 53, 255);" class="">2</span> ..< i {</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(195, 34, 117);" class="">if</span> i % j == <span style="color: rgb(4, 53, 255);" class="">0</span> {</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(195, 34, 117);" class="">continue</span> candidate</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""> <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>