Hard Mode: The Clonable States

Mission 3: The No-Cloning Mystery. Part of the Quantum Courier Service, a free course from the Oxford University Quantum Information Society.

The No-Cloning Theorem says arbitrary states can't be copied, yet some special, "classical-like" states are trivially clonable. As a numeric stand-in: a state indexed i is clonable exactly when i is a perfect square.

The job: write solve(n) that returns the sum of every clonable index from 1 to n inclusive: the sum of all perfect squares i with 1 <= i <= n.