Number of 1st Jan Sundays between year a and b.

34 Views Asked by At

Given two year number a and b (eg a=1000 b=2000). Find the number of 1st January Sundays? Given 1st Jan 2001 was Monday?

I figured that day sequence repeat after 28 years. But produced wrong answer. Help me figure it out.

PS: This was actually programming question and i wanted to get a O(1) solution.