Project Euler #3 in C# - largest prime factor
Here's my solution to this problem 

    static void Main(string[] args)
    {
        long num = 600851475143;
        int count = 3;
        Stopwatch sw = Stopwatch.StartNew();
        while (num &gt; 1)
        {
            if (num%count == 0)
            {
                num /= count;
            }
            else
            {
                count += 2;
            }
        }
        sw.Stop();
        Console.WriteLine("The largest prime factor of the number {0} is {1} ", 600851475143, count);
        Console.WriteLine("Time to calculate in milliseconds : {0}", sw.ElapsedMilliseconds);
        Console.ReadKey();
    }


First of all most of the exercises you will find on Project Euler will require some math formula or concept in order to achieve the highest possible performance. It's not pure programming and thus not the best place to practice it in my opinion (ofc assuming you don't know all the formulas) you will probably learn more math than programming in the process which is a good thing if that's what you are looking for. Long story short look for formula before you go into the programming.

Back to your actual code : 

Why is your code working slow ? 
 There are few points here that I want to make first method calls are slower than just a bunch of code in a single method again some problems you will find later in Project Euler will be pretty easy to solve but hard to optimize so the usual C# code has everything separated in methods and classes because the performance loss is not that big in a normal project however here this might be your only bottleneck in some cases. You should always think in perspective what if you had even bigger number ? Would your method still work fast enough ? A working program doesn't mean that it's a good program.

Next you start thinking what can you improve and why exactly you are doing certain things. Do you really need to know every single number that is prime ?

In my solution there is simple prime factorization starting from the smallest prime we keep increasing the current number we have until we get a number that we can divide only by itself i.e the  largest prime factor. 100,000 iterations run for about 3000-3200 ms on my machine.