• + 0 comments

    c#

    public static int divisors(int n)

    {
        int divisors = 0;
        if (n % 2 != 0)
        {
            return divisors;
        }
        else for (int i = 1; i <= Math.Floor(Math.Sqrt(n/2)); i++)
        {
            if ((n/2) % i == 0)
            {
                divisors++;
                if (i*i != n/2)
                {
                    divisors++;
                }
            }
        }
        return divisors;
    }