Project Euler 539 - Odd Elimination

Official link:

Thought Process

After brute forcing the first few values I found where there is a formula listed.

Apparently finding P(n) was a problem on Leetcode and here is a great video explaining how to derive P(n). Now lets solve for S(n)

Interactive Code

Enter an Integer (yourinput)

Code will output S(yourinput)