Now, why it works: a non-leap year is 365 days = 52 weeks + 1 day. That extra day pushes every date one day forward through the week from one year to the next: last year, November 20 was on Thursday, but this year it will be on Friday.
And each leap day pushes each date an extra day forward through the week: November 20 this year is on Friday, but next year it will be on Sunday, because the ‘+1 day’ does its usual pushing November 20 one day forward, and so does the leap day, so it gets pushed forward two days.
So a given date gets pushed forward through the week one day for each year, plus one day for each intervening leap day.
But every 7 days it gets pushed forward just gets you back to the same day of the week. So that’s why you divide by 7 and only keep your remainder: you’re tossing out as many multiples of 7 as you can, because they just tell you how many times that date has been pushed around the week and back to its starting place again.
The remainder is the part that tells you the actual change, after you’ve gotten back to the starting place for the last time.
And since a date is being pushed forward through the week as you go forward through time, if you’re working backwards in time, you count backwards. So going from 2015 to a past year, you take the remainder and count backwards through the week.
But if you wanted to know what day a future date fell on, you’d count forwards. November 20, 2050 moves forward 35 + 9 = 44 days, 44 = 7*6 + 2 so that’s 2 days forward, really. November 20, 2050 falls on a Sunday.
One note about dates before 1900 or after 2100: 1900 and 2100 aren’t leap years. Ditto any other year evenly divisible by 100 but not by 400. So if you want to figure out the day of the week of a date in A.D. 2101, when war was beginning ;), make sure you don’t inadvertently count the nonexistent leap day in 2100.