You have n cards that have been numbered from 1 to n. You will divide these cards into three stacks such that, the sum of the numbers of any pair of cards taken from any stack will not be a perfect square. Under this condition what is the maximum value that n can take?
If n=9, three stacks can be divided as (1,2), (3,4,7,8), (5,6,9) and the sum of any pair will not be a perfect square.