### need a little help

Heyy! :) I just started learning programing and there is a little assigment that i need to do, but i cant figure out why my program is not doing what it should do. If i look at it, everything seems correct, but when i try to run it, it never stops.
I have to find minimal number m, where m=a^3+b^3=c^3+d^3. It should print out 1729, but it doesnt.
No idea how to fix this. :(

 ``12345678910111213141516171819202122232425262728293031323334353637`` ``````#include #include using namespace std; int maks(int num1, int num2); int main() { int atgr,m,n,sk=100; for (int k=1; k<=sk; k++) for (int l=1; l<=sk; k++){ for (int i=1; i<=sk; i++){ for (int j=1; j<=sk; j++){ m= k*k*k + l*l*l; n= j*j*j + i*i*i; if(k!=l && k!=i && k!=j && l!=i && l!=j && i!=j){ cout<
You are missing a set of curly brackets. There should be one after the first for statement. If not, k will repeatedly initialize back to one, even though it is repeatedly incremented by one as well. It would just flop between one and two for infinity. At least that's what I think it would do. I could be wrong. I'm new to programming myself.
Line 13
 `` `` `` for (int l=1; l<=sk; k++){``

You probably meant l++;
oh, yeah. but it is still doing the same thing.
 ``` #include using namespace std; int maks(int num1, int num2); int main() { int atgr,m,n,sk=100; for (int k=1; k<=sk; k++){ for (int l=1; l<=sk; l++){ for (int i=1; i<=sk; i++){ for (int j=1; j<=sk; j++){ m= k*k*k + l*l*l; n= j*j*j + i*i*i; if(k!=l && k!=i && k!=j && l!=i && l!=j && i!=j){ cout<
Last edited on
lol Your program keeps running because the inner loop is forced to execute 100 million times.
Topic archived. No new replies allowed.