list(lim)=constructOdd(lim,[3]);

constructOdd(lim,start)={
	my(v=vectorsmall(lim\=1,i,1),u=List(),maxpr=2,alsodone=[],i);
	\\ v is a binary vector: 1 means the element has not yet been removed, 0 means the element has already been removed.
	\\ u is a list of the accepted elements (those that will certainly be in the sequence).
	\\ maxpr is the last prime which has been checked. Primes <= maxpr will not be tested again.
	\\ alsodone is a vector of the primes > maxpr which have also been tested. When possible these will be removed and maxpr incremented.
	\\ i is the element under consideration.
	for(i=1,vecmax(start),v[i]=0);
	for(i=1,#start,v[start[i]]=1);
	forstep(i=2,lim,2,v[i]=0);
	i=vecmin(start)-2;
	while(i<=lim-2,
		if(!v[i+=2],next);
		listput(u,i);
		my(tmp=Vec(u));
		forprime(p=maxpr+1,#u,
			if(#vecsort(tmp%p,,8)==p,
				listpop(u);
				forstep(j=i,lim,p,v[j]=0);
				if(nextprime(maxpr+1)==p,
					maxpr=p;
					alsodone=vecsort(alsodone,,8);
					for(k=1,#alsodone,
						if(nextprime(maxpr+1)==alsodone[k],
							maxpr=alsodone[k];
							if(#alsodone>k,
								alsodone=alsodone[2..#alsodone];
								k--
							,
								alsodone=[];
								break
							)
						,
							break
						)
					)
				,
					alsodone=concat(alsodone,p)
				);
				break
			)
		)
	);
	Vec(u)
};