We investigate connections between the continuum and atomistic descriptions of deformable crystals, using certain interesting results from number theory. The energy of a deformed crystal is calculated in the context of a lattice model with general binary interactions in two dimensions. A new bond counting approach is used, which reduces the problem to the lattice point problem of number theory. The main contribution is an explicit formula for the surface energy density as a function of the deformation gradient and boundary normal. The result is valid for a large class of domains, including faceted (polygonal) shapes and regions with piecewise smooth boundaries.