It’s honestly best to focus on getting yourself through the fast as opposed to calculating it. That being said, just get your BMR or TDEE, multiply by 40, and divide by 3500 (the calories in 1 lbs of fat).
I’m on day 25 myself and can confirm that you’re in for a hell of a journey! It can also get pretty boring so make sure you come up with plenty of things to do during the 40 days.
Unless you are just looking for quick weight loss and regain, I don’t think a 40 day fast is ideal.
You’ve gone from 100lbs to 170lbs in ‘a couple of years’. What happened for a 70lbs weight gain to occur?
That’s a large amount of weight to gain in a short period of time.
I would perhaps try a different protocol?
I’m speaking anecdotally aa I did a 40 day fast over a year ago and my weight has fluctuated between 109-115lbs, which I think is somewhat reasonable.
Good luck with whatever you choose!