C # program to print nearest element with at least one common prime factor .
using System ; using System . Collections . Generic ; public class GFG { static int MAX = 100001 ; static int INF = Int32 . MaxValue ; static int [ ] primedivisor = new int [ MAX ] ; static int [ ] dist = new int [ MAX ] ; static int [ ] pos = new int [ MAX ] ; static int [ ] divInd = new int [ MAX ] ; static List < List < int > > divisors = new List < List < int > > ( ) ;