Added gcd function to Entity.java