valueDiff for arrays?
Brian Milby
brian at milby7.com
Mon Aug 6 19:39:52 EDT 2018
2 should be included, but the original optimized version skipped it.
Thanks,
Brian
On Aug 6, 2018, 6:25 PM -0500, Niggemann, Bernd via use-livecode <use-livecode at lists.runrev.com>, wrote:
> This also helps a bit. Where is Hermann?
>
> ---------------------
> 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
> --------------------
>
> This is a modified Brian´s version built upon Alex's version
>
> Note that Brian seems to find one additional prime.
>
> Kind regards
> Bernd
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list