There was an error in the code I posted. It should read "if pN >= 10000 then" instead of "if pN > 10000"
this is the corrected version ----------------- function get_primes pN local tMroot, tPrimes, tIsItPrime, tYes, tNo put numtobyte(66) into tYes put numtobyte(65) into tNo if pN < 2 then return empty if pN = 2 then return 2 put 2 into tPrimes put trunc(sqrt(pN)) - 1 into tMroot if pN >= 10000 then local tTenThousand repeat 10000 put tYes after tTenThousand end repeat repeat pn div 10000 put tTenthousand after tIsItPrime end repeat end if repeat pn mod 10000 put tTenthousand after tIsItPrime end repeat repeat with i = 3 to tMroot step 2 if byte i of tIsItPrime is tNo then next repeat put cr & i after tPrimes repeat with j = i^2 to pN step i put tNo into byte j of tIsItPrime end repeat end repeat repeat with i = tMroot + (tMroot + 1) mod 2 to pN - 1 step 2 if byte i of tIsItPrime is tYes then put cr & i after tPrimes end repeat return tPrimes end get_primes --------------- Kind regards Bernd _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode