First version, working efficient divisibility