H
H
hishlishter2020-10-04 12:54:23
Pascal
hishlishter, 2020-10-04 12:54:23

Find the smallest natural number n that can be represented in two different ways as the sum of cubes of two natural numbers x3 + y3 (x >= y)?

Find the smallest natural number n that can be represented in two different
ways as the sum of cubes of two natural numbers x3 + y3 (x >= y)
pascal code:

const
  eps = 0.00001;

var
  x, y, n, x1, y1: longint;
  tmp: real;

begin
  x := 0;
  while true do
  begin
    inc(x);
    y := 0;
    while (y < x) do
    begin
      inc(y);
      n := x * x * x + y * y * y;
      x1 := x;
      y1 := y;
      while x1 > 1 do
      begin
        dec(x1);
        tmp := exp(ln(n - x1 * x1 * x1) / 3);
        if trunc(tmp) > x1 then
          break;
        if (Frac(tmp) < eps) or (1 - Frac(tmp) < eps) then
        begin
          y1 := round(tmp);
          writeln(x, ' ', y, ' ', x1, ' ', y1);
          readln;
        end;
      end;
    end;
  end;
end.


But I'm not sure about the correctness, and I also need to write in c ++, with which I had problems (

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question