If W is of the order O(N) then the total ops you suggest are in the order O(N log(N)).
If indeed we can device a test which can test whether W or any number below divides N in the order O(log(N)^k then we can use it to binary search for factors, which means we can prime factorize in polynomial ( log(N)). I conjecture that a test like AKS primality test can be made but I am not yet able to make it. Any ideas?
The case W=N is primality testing which is in P by AKS. Now being in P does not mean O(log(N)) but O(poly(log(N)) . So you are asking for an improvement of AKS. Sorry if I am missing something basic.