Project Euler 539 - Odd Elimination

Official link: https://projecteuler.net/problem=539

Thought Process

After brute forcing the first few values I found https://oeis.org/A347325 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)