The average ionic energy of NaCl crystal was calculated with computer,the function about relationship of the average ionic energy and the crystal size was obtained with data conformation. Results showed: the average ionic energy of NaCl crystal decreased with crystal size; When the crystal was large enough, the average ionic energy reach a value 1 74732496, which was reported as Madelung constant.