Adapted Green's code to calculate values of gamma.