Den lördag 16 januari 2016 kl. 23:30:48 UTC+1 skrev Chris Angelico: > On Sun, Jan 17, 2016 at 9:23 AM, <jonas.thornv...@gmail.com> wrote: > > function factor_it(i){ > > prime=true; > > sqroot=Math.floor(Math.sqrt(i)); > > for (j=2;j<sqroot;j++){ k=i/j; prime=!Number.isInteger(k); if (prime) > > {return prime}} > > return prime; > > } > > A couple of potential problems here. The first thing that comes to > mind is that floating point inaccuracy is going to bite you long > before the numbers "seem huge" to someone who's thinking about 2**53. > The second is an off-by-one error: a perfect square may come up as > prime. > > Check for those and see how it looks. > > Also, check your double-use of the 'prime' variable, which also > appears to be global here. > > ChrisA
Thank you Chris your comment resolved it double use of j in two different functions and loops. -- https://mail.python.org/mailman/listinfo/python-list