fix #5210, factor() failing for some integer types