%mathpiper,def="FactorQS"

//  numbers

// The bud of an Quadratic Seive algorithm
// congruence solving code must be written first
Function("FactorQS",{n})[
	Local(x,k,fb,j);
	// optimal number of primes in factor base
	// according to Fundamental Number Theory with Applications - Mollin, p130
	k:=Round(N(Sqrt(Exp(Sqrt(Ln(n)*Ln(Ln(n)))))));
	fb:=ZeroVector(k);
	For(j:=1,j<=k,j++)[
		fb[j]:=NextPrime(j);
	];
];

%/mathpiper
