Hard Mode: Correlated Pairs
Mission 4: Entanglement. Part of the Quantum Courier Service, a free course from the Oxford University Quantum Information Society.
Entangled particles come in correlated pairs. As a numeric stand-in: two indices a < b count as a "correlated pair" if their sum a + b is a perfect square.
The job: write solve(n) that returns how many correlated pairs (a, b) exist with 1 <= a < b <= n.