How to resolve the algorithm Euler's sum of powers conjecture step by step in the Scala 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 Scala 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 Scala programming language
Source code in the scala programming language
import scala.collection.Searching.{Found, search}
object EulerSopConjecture extends App {
val (maxNumber, fifth) = (250, (1 to 250).map { i => math.pow(i, 5).toLong })
def binSearch(fact: Int*) = fifth.search(fact.map(f => fifth(f)).sum)
def sop = (0 until maxNumber)
.flatMap(a => (a until maxNumber)
.flatMap(b => (b until maxNumber)
.flatMap(c => (c until maxNumber)
.map { case x$1@d => (binSearch(a, b, c, d), x$1) }
.withFilter { case (f, _) => f.isInstanceOf[Found] }
.map { case (f, d) => (a + 1, b + 1, c + 1, d + 1, f.insertionPoint + 1) }))).take(1)
.map { case (a, b, c, d, f) => s"$a⁵ + $b⁵ + $c⁵ + $d⁵ = $f⁵" }
println(sop)
}
You may also check:How to resolve the algorithm Bitmap/Midpoint circle algorithm step by step in the Tcl programming language
You may also check:How to resolve the algorithm Vigenère cipher step by step in the Julia programming language
You may also check:How to resolve the algorithm 100 doors step by step in the ECL programming language
You may also check:How to resolve the algorithm Box the compass step by step in the Lua programming language
You may also check:How to resolve the algorithm Additive primes step by step in the uBasic/4tH programming language