C# Count Non Divisible
static int[] CountNonDivisible(int[] a)
{
    var size = a.Length;
    var nondivisor = new int[size];
    var occurrences = new int[a.Max() + 1];

    foreach (var v in a)
    {
        occurrences[v]++;
    }

    for (int k = 0; k < size; k++)
    {
        var v = a[k];
        var count = 0;
        var i = 1;
        while (i * i <= v)
        {
            if (v % i == 0)
            {
                count += occurrences[i];
                if (v / i != i)
                {
                    count += occurrences[v / i];
                }
            }
            i++;
        }
        nondivisor[k] = size - count;
    }

    return nondivisor;
}

This counts how often each value appears, then subtracts the divisor matches so you get the non-divisible count for each item.