title: Program that finds the largest prime factor
body: <p>So I wrote a code for finding the largest factor for my learning procces on Project Euler and it worked fine and I got the right answer. Tho I saw diffrent solutions and they were "longer" and looked more complicated. So my question is, is there anything my code is no taking care of for lets say different number or is there a better way to do this task? I am trying to learn different ways of solving problems to get better at programming so I wonder if I should have done that code in a different way.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace prime_factor
  {
    class Program
    {
      static void Main(string[] args)
      {
          long n = 600851475143;
          int largest = 0;
          for (int i = 1; i&lt;=n; i++)
          {
              if (n%i == 0)
              {
                  Console.WriteLine(i);
                  n /= i;
                  largest = i;
  
              }
          }
          Console.WriteLine(largest);
          Console.ReadLine();
      }
    }
  }
  </code></pre>