In VBA
Sub prim()
Range("c4").Select
a = ActiveCell
Range("d4").Select
c = ActiveCell
For i = 2 To 100
For j = 1 To 100
b = a / i
d = c / i
If b = j Then
For x = 2 To 100
If d = x Then
Range("c6") = i
End If
Next x
End If
Next j
Next i
End Sub