magic cube

A magic cube is similar to a magic square but has three dimensions instead of two. It contains the integers from 1 to n3 and has 3n2 + 4 lines that sum correctly. All rows, columns, pillars, and the four triagonals (three-dimensional diagonals) must sum to the constant ½n(n3 + 1). A cross-section through a magic cube is a magic square.