
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
For each even positive integer  $x$ , let  $g(x)$  denote the greatest power of  $2$  that divides  $x$ .  For example,  $g(20)=4$  and  $g(16)=16$ .  For each positive integer  $n$ , let  $S_n=\sum_{k=1}^{2^{n-1}}g(2k).$   Find the greatest integer  $n$  less than  $1000$  such that  $S_n$  is a perfect square.

Present the answer in LaTex format: \boxed{Your answer}
user