Help in this number theory problem

How I solve this problem by python? Please help and give me a idea to solve this.
It is a question from the book 104 number theory problems.

Problem
If x,y,z are natural numbers where x and z are odd numbers and y is a multiple of 8, then how many solutions does the equation given below have?

x+y+z=2014

You can solve this mentally.
It’s 126253.
Let’s say it’s
x+z=k//assuming k is even
We have solutions from
1 k-1
3 k-3
5 k-5

k-1 1
So the number of solutions is k/2.
Now if y is 8 , we get 2014 - 8 /2 = 1003
if y is 16, we get 2014 - 16 /2 = 999
This goes on until we reach 3
so we get 3+ 7 + 11 … 1003
That sum is 126253.

1 Like

Thanks a lot :slightly_smiling_face:. I understand your answer and now I can also do it with python easily.

c=0
for y in range(8,2014,8):
p=2014-y
for x in range(1,p,2):
z=p-x
c+=1
print('total number of solutions : ',c)

What is answer given in the book?

@akshitm16 It is 126253.

ohk

1 Like