You might be wondering how you can calculate what the target or difficulty should be to maintain a 10 minute average block time?
The algorithm basically looks at the recent history of blocks produced and is able to see how fast or slow they have been found.
If they have been found faster than 10 minutes on average then we can calculate roughly how much hashing power has been added to the network and adjust the difficulty appropriately.
If they have been found slower than 10 minutes then we can do the inverse.