3
$\begingroup$

Are there more natural numbers from $1$ to $1,000,000$ inclusive that can be represented as the sum of a perfect square and cube, or numbers that can't be?

  • 2
    why does this have a downvote are you kidding me?2017-01-10
  • 1
    Little typo, $n,m$ rather $n^2,m^3$ or change definition of $A,B$. In addition to limiting we have also to take care about duplicates, e.g. $32^2+1^3=10^3+5^2$.2017-01-10
  • 0
    Typo noted. Sorry will be more careful next time2017-01-10
  • 0
    Why did you delete all of the context associated with the problem?2017-01-24

2 Answers 2

4

Your argument shows that there are at most $100,000$ numbers up to $1,000,000$ that can be represented as the sum of a square and a positive cube. This is enough to answer your question.

  • 0
    Ahh but of course! Thank you!2017-01-10
2

your answer works as is and in fact the approximation is really good. I tried to get a tighter result by bounding it by the following sum:

$\sum\limits_{i=1}^{100} \sqrt{10^6-i^3}$. This expression can be bounded by the integral of the curve

$\int\limits_{x=0}^{100}\sqrt{10^6-x^3}dx$, however, since the function $x^3$ is convex and $\sqrt{x}$ is concave the improvement is really small:

enter image description here

we only obtain the slightly better bound of $84130$.

On the other hand, the actual result is $76356$ as can be found with the following code:

#include 
using namespace std;

const int MAX=1000000;
int A[MAX];

int main(){
    int res=0;
    for(int x=0;x*x
  • 0
    76272 actually, x=0 is excluded by OP.2017-01-10
  • 0
    I think only $y=0$ was excluded.2017-01-10
  • 0
    @JorgeFernándezHidalgo: $x=0$ was _implicitly_ excluded by the working in the question: $A$ does not contain $0$.2017-01-10
  • 0
    And at the other end, you should have `<= MAX` wherever you have `< MAX`. (So you need `int A[MAX+1];`)2017-01-10