This is not in LCB script, but you posting this reminded me of some code I
wrote a long time ago when I needed (for a programming challenge) to write
a function that would return primes up to 10^9 or so. That was far too
large to do the traditional "build an array of excluded values" sort of
thing,
You might be better off building the primes as a List, then converting to a
string at the end. Although the conversion of each number is only done once so
it probably doesn't make too much difference (apart from being a bit more LCBy).
In general LCB should be written to prefer structure over st