Gravitational force is affected by mass of object and distance between center of the objects taken. According to Newton, gravitational force is directly proportional to product of their masses and inversely proportional to square of their centers.
if,
gravitational force = G
mass of an object = m1
mass of another object = m2
distance between center of planets = d
According to newton law ,
\(G\propto m_1\times m_2\)
\(G\propto\frac1{d^2}\)