What is the latest WordPress that will work on PHP 5.2.17?

I think you’re looking at this the wrong way.

Having an old application that requires such a archaic PHP version is bad enough. That does not mean, your new WordPress installation needs to use that same old version though. Instead, I would suggest to keep PHP 5.2.17 for the legacy application and use the latest PHP version for WordPress.

There are various ways to do this, it all depends on how exactly your server is set up.