How to print the variables that satisfy the given condition

I am writing a simple program that prints the variables that satisfy the following equation 2^4 + 2^4 + 3^4 + 4^4 + 4^4 = 5^4. But I am just getting the empty screen.

Here is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int final = 0;
	for (int i = 1; i < 51; i++)
	{
		for (int j = 1; j < 51; j++)
		{
			for (int k = 1; k < 51; k++)
			{
				for (int x = 1; x < 52; x++)
				{
					if ((pow(i, 4) + pow(j, 4) + pow(k, 4)+pow(x,4)) == pow(15,4))
					{
						cout << "x = " << i << ", y = " << j << ", z = " << k << ", k = " << x << endl;
					}
				}
			}
		}
	}
	system("pause");
	return 0;
}
Last edited on
It really helps to be exact.

Look at your equation. Then look at line 17. There are two pretty major differences.

Line 19 is pretty confusing too. (I understand that names don’t matter here, but you should be pedantic anyway.)

Hope this helps.
Topic archived. No new replies allowed.