I am trying to write a program to find the largest prime factor of a very large number, and have tried several methods with varying success. All of the ones I have found so
You are trying to find the prime factors of a number. What you are proposing will work, but will still be slow for large numbers.... you should be thankful for this, since most modern security is predicated on this being a difficult problem.