How to resolve the algorithm Euler's sum of powers conjecture step by step in the Seed7 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Euler's sum of powers conjecture step by step in the Seed7 programming language

Table of Contents

Problem Statement

There is a conjecture in mathematics that held for over two hundred years before it was disproved by the finding of a counterexample in 1966 by Lander and Parkin. This conjecture is called Euler's sum of powers conjecture and can be stated as such: In 1966, Leon J. Lander and Thomas R. Parkin used a brute-force search on a CDC 6600 computer restricting numbers to those less than 250. The task consists in writing a program to search for an integer solution of

x

0

5

x

1

5

x

2

5

x

3

5

=

y

5

{\displaystyle x_{0}^{5}+x_{1}^{5}+x_{2}^{5}+x_{3}^{5}=y^{5}}

where all

x

i

{\displaystyle x_{i}}

and

y

{\displaystyle y}

are distinct integers between 0 and 250 (exclusive). Show an answer here. Related tasks are:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Euler's sum of powers conjecture step by step in the Seed7 programming language

Source code in the seed7 programming language

$ include "seed7_05.s7i";

const func integer: binarySearch (in array integer: arr, in integer: aKey) is func
  result
    var integer: index is 0;
  local
    var integer: low is 1;
    var integer: high is 0;
    var integer: middle is 0;
  begin
    high := length(arr);
    while index = 0 and low <= high do
      middle := (low + high) div 2;
      if aKey < arr[middle] then
        high := pred(middle);
      elsif aKey > arr[middle] then
        low := succ(middle);
      else
        index := middle;
      end if;
    end while;
  end func;

const proc: main is func
  local
    var array integer: p5 is 249 times 0;
    var integer: i is 0;
    var integer: x0 is 0;
    var integer: x1 is 0;
    var integer: x2 is 0;
    var integer: x3 is 0;
    var integer: sum is 0;
    var integer: y is 0;
    var boolean: found is FALSE;
  begin
    for i range 1 to 249 do
      p5[i] := i ** 5;
    end for;
    for x0 range 1 to 249 until found do
      for x1 range 1 to pred(x0) until found do
        for x2 range 1 to pred(x1) until found do
          for x3 range 1 to pred(x2) until found do
            sum := p5[x0] + p5[x1] + p5[x2] + p5[x3];
            y := binarySearch(p5, sum);
            if y > 0 then
              writeln(x0 <& "**5 + " <& x1 <& "**5 + " <& x2 <& "**5 + " <& x3 <& "**5 = " <& y <& "**5");
              found := TRUE;
            end if;
          end for;
        end for;
      end for;
    end for;
    if not found then
      writeln("No solution was found");
    end if;
  end func;

  

You may also check:How to resolve the algorithm Enforced immutability step by step in the Elixir programming language
You may also check:How to resolve the algorithm Polymorphism step by step in the Pop11 programming language
You may also check:How to resolve the algorithm AKS test for primes step by step in the Swift programming language
You may also check:How to resolve the algorithm Loops/Break step by step in the Rust programming language
You may also check:How to resolve the algorithm Loops/Break step by step in the Smalltalk programming language