• + 0 comments

    Python 3

    def divisors(n):
        c2 = 0
        p = 1
    
        while p * p <= n:
            if n % p == 0:
                if p % 2 == 0:
                    c2 += 1
                if p != n // p and (n // p) % 2 == 0:
                    c2 += 1
            p += 1
    
        return c2
    

    Java 8

       public static int divisors(int n) {
            int c2 = 0;
            int p = 1;
            while (p * p <= n) {
                if (n % p == 0) {
                    if (p % 2 == 0) c2++;
                    if (p != n / p && (n / p) % 2 == 0) c2++;
                }
                p++;
            }
            return c2;
        }