Function to return the count of numbers that when added with n give a perfect square
function countPairsWith ( $ n , $ perfectSquares , $ nums ) { $ count = 0 ; for ( $ i = 0 ; $ i < count ( $ perfectSquares ) ; $ i ++ ) { $ temp = $ perfectSquares [ $ i ] - $ n ;