calculating prime factors for N