In the January 11, 2018 episode of Numberphile, the challenge of arranging the first n integers into a sequence where the sum of two consecutive integers is a perfect square is presented. In this project, we transform the original Numberphile’s Square-Sum problem by replacing “perfect square” with “square mod m” where m is a positive integer. We also count first and last terms of the sequence as consecutive.
The Numberphile video presents a graph theory approach to solving the problem, and we use a similar technique. For a given m and n, we draw n vertices, where each integer is a vertex. Then, we connect two vertices with an edge if their sum equals a square modulo m - we denote this graph as Gm(n). If there exists a Hamiltonian cycle in our graph, we have found our desired sequence. For m= [2,10] we have found the necessary and sufficient conditions for n so that Gm(n) contains a Hamiltonian cycle. Further, we have found a bound for the degree of any vertex in Gm(n).
In addition, we have explored techniques to find a Hamiltonian cycle in Gm(n) computationally. Even though Hamiltonian cycle detecting (the decision version) is an NP-Complete problem, it appears that an O(n!) backtracking algorithm is surprisingly fast for m = n, where m is a prime. Based on our computational results we have also conjectured that there always exists a Hamiltonian cycle for m = n for prime m > 9.