Python3 program to print nearest element with at least one common prime factor .
MAX = 100001 NEW_LINE INF = 10 ** 9 NEW_LINE primedivisor = [ 0 for i in range ( MAX ) ] NEW_LINE dist = [ 0 for i in range ( MAX ) ] NEW_LINE pos = [ 0 for i in range ( MAX ) ] NEW_LINE divInd = [ 0 for i in range ( MAX ) ] NEW_LINE divisors = [ [ ] for i in range ( MAX ) ] NEW_LINE