added random functionallity to prime wfactorization