不妨设则有
于是可以编写以下程序:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int n = 3;
int max_val = 1000;
for (int x = 1; x <= max_val; x++) {
for (int y = x; y <= max_val; y++) {
for (int z = y; z <= max_val; z++) {
if (pow(x, n) + pow(y, n) == pow(z, n)) {
cout << "Fermat's Last Theorem is false!" <&