Efficiently Calculate the number of pairs in array satisfying the condition that gcd(a[i] , a[j])…

Problem: