This question already has an answer here:

I'm wondering if anyone knows a formula for how to calculate the mining difficulty based on the current hash rate. For an example, if the BTC network would reach 20 million TH/s. Thank You!

marked as duplicate by Max Vernon, Pieter Wuille, pebwindkraft, Murch Dec 8 '17 at 4:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.