Thanks guest answerer :)

I did this by hand and got the same answer.

N is a four-digit positive integer. Dividing N by 9 , the remainder is 5. Dividing N by 7, the remainder is 2. Dividing N by 5, the remainder is 4. What is the smallest possible value of N?

N=9A+5 N=7B+2 N=5C-1

Solve diophantine equations.

9A+5=7B+2

A whole stack of work got me down to A=-12+7T B=-15+9T

Which both gave me

N=-103+63T

So now I have N=-103+63T and N=5C-1

Solve diophantine equations.

-103+63T = 5C-1

A whole stack more work got me to

T=204+5X and C=2550+63X

Which both gave me the general solution N=12749+315X

I'm only interested in 4 digit solutions so

\(1000 \le N <10000\\ 1000\le12749+315X<100000\\ -11749\le315X<-2449\\ -37.3

When X=-37 N=1094 When X=-8 N=9914

-8--37+1=30

There are 30 four digit solutions, the smallest is 1094 and the largest is 9914

-------------------

looking at what I have done, I should have simplified the general term first.

N=12749+315X

12749/315=approx 40.5

12749-40*315=149

Nicer general term

N=149+315Y

It is easeier to check that this is correct too.

If anyone wants a more detailed solution then just ask.