Tip of the Day : How to Read and Load an Excel 2007 or Excel 2010 File Without Using Import/Export Utility

SQL Server Helper - Tip of the Day

Beals Conjecture - A Search for Counterexamples Using SQL Server

According to Wikipedia, Beal's conjecture is a conjecture in number theory proposed by Andrew Beal in 1993.  While investigating generalizations of Fermat's last theorem in 1993, Beal formulated the following conjecture:

If

Ax + By = Cz

where A, B, C, x, y and z are positive integers with x, y, z > 2, then A, B, and C have a common prime factor.

For a proof or counterexample published in a refereed journal, Beal initially offered a prize of $ 5,000 in 1997, rising to $50,000 over ten years, and now has been raised to $1,000,000 (as of June 6, 2013).

In finding a counterexample, with the help of the [dbo].[spt_values] table in the master database, a simple query can be used to identify different possible values for the six variables that will satisfy the equation.

DECLARE @MaxBase      INT
DECLARE @MaxPower     INT

SET @MaxBase  = 10
SET @MaxPower = 10

SELECT A.[Number] AS A, B.[Number] AS B, C.[Number] AS C, x.[Number] AS x, y.[Number] AS y, z.[Number] AS z
FROM (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values]
      WHERE [type] = 'P' AND [number] BETWEEN 1 AND @MaxBase) A
      CROSS JOIN
     (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values]
      WHERE [type] = 'P' AND [number] BETWEEN 1 AND @MaxBase) B
      CROSS JOIN
     (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values]
      WHERE [type] = 'P' AND [number] BETWEEN 1 AND @MaxBase) C
      CROSS JOIN
     (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values]
      WHERE [type] = 'P' AND [number] BETWEEN 3 AND @MaxPower) x
      CROSS JOIN
     (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values]
      WHERE [type] = 'P' AND [number] BETWEEN 3 AND @MaxPower) y
      CROSS JOIN
     (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values] 
      WHERE [type] = 'P' AND [number] BETWEEN 3 AND @MaxPower) z
WHERE POWER(A.[Number], x.[Number]) + POWER(B.[Number], y.[Number]) = POWER(C.[Number], z.[Number])
ORDER BY A.[Number], B.[Number], C.[Number]

Here's the first ten values for the six variables that satisfy the equation:

A    B    C    x    y    z
---  ---  ---  ---  ---  ---
2    2    2    4    4    5
2    2    2    8    8    9
2    2    2    3    3    4
2    2    2    7    7    8
2    2    2    6    6    7
2    2    2    5    5    6
2    2    2    9    9    10
2    2    4    5    5    3
2    2    4    7    7    4
2    2    4    9    9    5

Unfortunately, no counterexample was identified using this query. Also, as the value of the x, y and z variables grow bigger, the result becomes incorrect. As an example, increasing the value of the @MaxPower to 20 yields the following incorrect results:

A    B    C    x    y    z
---  ---  ---  ---  ---  ---
1    7    7    3    20    20
1    7    7    4    20    20
1    7    7    5    20    20
1    7    7    6    20    20
1    7    7    7    20    20
1    7    7    8    20    20
1    7    7    9    20    20
1    7    7    10   20    20
1    7    7    11   20    20
1    7    7    12   20    20

Back to Tip of the Day List Next Tip