Script to set Set play rate, so that the montage plays a total of exactly 1 second?

My math isn’t great, I’m not sure if I’m having a brain fart right now or why I can’t figure this out.

What I’m trying to do is take the length of a montage, it can randomly be 4 seconds long, or 5 or even 10 for example…

I want to set the play rate of the montage that plays the animation in the span of exactly 1 second.

So if it was 4 seconds long, the play-rate should have to be 8?. So i just multiply *2 of the length? Can anyone confirm if this is correct way to go about this?

Thanks in advanced