static void Main(string[] args) { BigInteger[] index = new BigInteger[(100 - 1) * (100 - 1)]; for (int a = 2; a <= 100; a++) // Outer for loop a for (int b = 2; b <= 100; b++) // Inner for loop b index[(100 - 1) * (a - 2) + (b - 2)] = BigInteger.Pow(a, b); // Sort out and find all unique elemengts BigInteger[] onlyUnique = index.Distinct().ToArray(); Console.WriteLine("Nbr of unique elements are: {0}", onlyUnique.Length); }