Horje
largest prime factor of a number Code Example
largest prime factor of a number
		static long LargestFactor(long n)
        {
            long lastFactor;
            if (n%2==0)
            {
                lastFactor = 2;
                n/=2;
                while (n % 2 == 0)
                    n/=2;
            }
            else
            {
                lastFactor = 1;
            }
            long factor = 3;
            long maxFactor = Convert.ToInt64(Math.Sqrt(n));
            while (n > 1 && factor <= maxFactor)
            {
                if(n % factor == 0)
                {
                    n/=factor;
                    lastFactor=factor;
                    while (n % factor == 0)
                        n/= factor;
                    maxFactor = Convert.ToInt64(Math.Sqrt(n));
                }
                factor += 2;
            }
            if (n == 1)
                return lastFactor;
            else
                return n;
        }




Csharp

Related
C# check control type Code Example C# check control type Code Example
c-sharp - get current page url/path/host Code Example c-sharp - get current page url/path/host Code Example
how to make build events always run visual studio Code Example how to make build events always run visual studio Code Example
death transition unity 2d Code Example death transition unity 2d Code Example
C# read GroupComponent using regex Code Example C# read GroupComponent using regex Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11