I have got a puzzle to find out the smallest n (natural number) that:  

n modulus 2 is 1.  

n modulus 3 is 0.  

n modulus 4 is 1.  

n modulus 5 is 1.  

n modulus 6 is 3.  

n modulus 7 is 0.  

n modulus 8 is 1.  

n modulus 9 is 0. 

It is not hard to find out that n % 63 == 0 and n % 40 == 1. Then I wrote a small program to find out the smallest n is 441. 

But my question is, is there any mathematical way in finding out the smallest number in the last part, rather than using a program to traverse? Or is traverse the only approach in this situation?