Write all solutions for a^3 + b^3 = c^3 + d^3

https://news.ycombinator.com/item?id=7892274
by saltcookie • 12 years ago
2 2 12 years ago

this runs the fastest without memory overhead

int Search(){ int MAX = 10000000; for(int a = 0; a < MAX; a++){ int a3 = a * a * a; if(a3 > MAX) break; for(int b = a; b < MAX; b ++){ int b3 = b * b * b; if(a3 + b3 > MAX)break; for(int c = 0; c < a; c++){ int c3 = ccc; int m = a3 - c3; int d = b+1; while(true){ int d3 = d * d * d; if(d3-b3 <= m){ if((d3 - b3) == m){ count++; PUSH_SOLUTION(a3, b3, c3, b3, a, b, c, d); } d++; continue; } else break; } } } } return 0; }

Related Stories

Loading related stories...

Source preview

news.ycombinator.com