# Fermat's last theorem

## Recommended Posts

I made a program that calculates Fermat's last theorem.

Unless AutoIt can calculate higher numbers, he seems to be correct.

Only issue with this program is that it fails at calculation #442 due to a limition in AutoIt and/or Windows.

His theorem is basically showing that in the Pythagorean theorem (A^2+B^2=C^2) that if the exponant is greater than two (2) then it will be incorrect.

EDIT: Writing Excel Export right now.

```#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <ExcelCOM_UDF.au3>
\$continue = 0
\$go = 1
\$EXCEL = 1
#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\Exp.kxf
\$Form1 = GUICreate("Exponential Generator", 1250, 447, 193, 125)
\$List1 = _GUICtrlListView_Create(\$Form1, "Exponant", 336, 8, 900, 432)
\$Input1 = GUICtrlCreateInput("3", 56, 32, 41, 21)
\$Label1 = GUICtrlCreateLabel("+", 104, 32, 10, 17)
\$Input2 = GUICtrlCreateInput("4", 120, 32, 41, 21)
\$Label2 = GUICtrlCreateLabel("=", 168, 32, 10, 17)
\$Input3 = GUICtrlCreateInput("5", 184, 32, 41, 21)
\$Label3 = GUICtrlCreateLabel("A^N      +       B^N  =       C^N", 64, 64, 155, 17)
\$Label4 = GUICtrlCreateLabel("Until Exponant Equals: ", 64, 88, 114, 17)
\$Input4 = GUICtrlCreateInput("", 184, 88, 73, 21)
\$Button1 = GUICtrlCreateButton("Begin Testing...", 120, 115, 150, 30)
\$Button2 = GUICtrlCreateButton("Export to Excel (Retests)", 120, 145, 200, 30)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
\$Msg = GUIGetMsg()
Select
Case \$Msg = \$GUI_EVENT_CLOSE
Exit
Case \$Msg = \$Button1
\$go = 1
\$continue = 0
_CALC()
Case \$Msg = \$Button2
;~          Sleep(1000)
;~          ControlSetText("Untitled - Notepad", "", "Edit1", \$text)
_Excel_CALC()
EndSelect
WEnd

Func _CALC()
If GUICtrlRead(\$Input4) = "" Then _Error("Please fill in the end input. -1 for infinate.")
If \$go = 1 Then
ControlDisable(\$Form1, "", \$Button1)
GUICtrlSetData(\$Button1, "Restart Program")
Do
\$continue = \$continue + 1
;=========>>>>ERROR CHECK THAT FAILS
If \$A^\$continue+\$B^\$continue = "1.#INF" Then
\$go = 0
EndIf
;=========>>>NO MORE CHECKZORZ
If \$go = 1 Then
If \$A^\$continue+\$B^\$continue >= \$C^\$continue Then
Else
EndIf
EndIf
\$go = 1
EndIf
EndFunc

Func _Excel_CALC()
If GUICtrlRead(\$Input4) = "" Then _Error("Please fill in the end input. -1 for infinate.")
\$oExcel = _ExcelBookNew(1)  ; Create new book in COM object, make it visible, overwrite if necessary
_ExcelWriteCell(\$oExcel, "Exponant", "A1", "1")
_ExcelWriteCell(\$oExcel, "A", "B1", "1")
_ExcelWriteCell(\$oExcel, "B", "C1", "1")
_ExcelWriteCell(\$oExcel, "C", "D1", "1")
_ExcelWriteCell(\$oExcel, "Total", "E1", "1")
_ExcelWriteCell(\$oExcel, "A+B=C?", "F1", "1")
If \$go = 1 Then
ControlDisable(\$Form1, "", \$Button1)
GUICtrlSetData(\$Button1, "Restart Program")
Do
\$continue = \$continue + 1
_ExcelWriteCell(\$oExcel, \$continue, "A" & \$continue)
_ExcelWriteCell(\$oExcel, \$A^\$continue, "B" & \$continue)
_ExcelWriteCell(\$oExcel, \$B^\$continue, "C" & \$continue)
_ExcelWriteCell(\$oExcel, \$C^\$continue, "D" & \$continue)
_ExcelWriteCell(\$oExcel, \$A^\$continue+\$B^\$continue, "E" & \$continue)
;=========>>>>ERROR CHECK THAT FAILS
;~          If \$A^\$continue+\$B^\$continue = "1.#INF" Then
;~              \$go = 0
;~          EndIf
;=========>>>NO MORE CHECKZORZ
;~          If \$go = 1 Then
If \$A^\$continue+\$B^\$continue >= \$C^\$continue Then
_ExcelWriteCell(\$oExcel, "YES", "F1", \$continue)
Else
_ExcelWriteCell(\$oExcel, "NO", "F1", \$continue)
EndIf
;~          EndIf
;~          \$go = 1
EndIf
EndFunc

Func _Error(\$msgbo="")
MsgBox(0, "", \$msgbo)
\$go = 0
EndFunc```
Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

##### Share on other sites

Why don't you just write the code in Excel?

##### Share on other sites

I didn't think of it until it was already done. lol

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

##### Share on other sites

Demonstrating by example doesn't prove a theorem like this... Despite all the examples you may show where a theorem works, all it takes is one counter-example for a theorem to fall apart and be considered false. Unless you can literally test every possible number (you can't, considering how the set of integers is infinitely large), then brute-force calculations won't do you any good, since you'll never know if a counter-example lies outside of the numbers you've tested (or the numbers you could possibly test). No amount of calculation power or increase in number limit would allow you to prove this to be true by brute-force.

Edited by -Ultima-

##### Share on other sites

Yeah. I realise that, but I believe that I've shown this to the extent of AutoIt.

That's why I added the...'sorta' in the title. lol

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

##### Share on other sites

Your problem with AutoIt recognizing these large numbers as infinity is unsolvable without making modifications to the AutoIt interpreter, you may as well remove the request to "fix it".

##### Share on other sites

Your problem with AutoIt recognizing these large numbers as infinity is unsolvable without making modifications to the AutoIt interpreter,

Actually, without making modifications to the way PC's are designed, and possibly the universe as well.

BTW, congratulations on your prestigious No. #1 programmer award!. I imagine your thinking regarding the panel of judges was a bit like the one time head of FerrariFiat, who said that a board of directors worked best if there was an odd number of directors, and three was too many.

I'm probably just old fashioned but I liked your "I'm a charging ma laser" avatar.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

##### Share on other sites

I'm probably just old fashioned but I liked your "I'm a charging ma laser" avatar.

Know what, I'll change it back just for you.

Was it this image: ??

##### Share on other sites

Know what, I'll change it back just for you.

Was it this image: ??

It was similar but I'm sure it wasn't that one, and I'm sure it said 'charging' not 'firing'.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

##### Share on other sites

It was similar but I'm sure it wasn't that one, and I'm sure it said 'charging' not 'firing'.

It's probably different then what I first had, but it's close. Right?

##### Share on other sites

It's probably different then what I first had, but it's close. Right?

It's very close

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...