-- Cheking the last Fermat's theorem -- -- Thanks Google for today's doodle that bring to my mind -- the last Fermat's Theorem. -- -- This is a small dumb try to catch an error on the theory, -- It crash on the wall because quickly reach the higher integer -- value, and never gets a cubic sum. -- -- Is nice to see how many cases of square sum exist, there are -- a lot of them, there are several couples of squares that produces -- the same sum. -- -- Please someone try to use an arbitrary values library. -- -- -- Marco Achury -- August 17, 2011 -- Released to public domain -- sequence powers object junk integer SquareSum integer CubicSum integer Number powers={} Number=814 -- 814 is the highest number we can test without error puts(1,"Filling powers table\n") for i=1 to Number by 1 do powers=append(powers,{i,power(i,2), power(i,3)}) end for -- Just for debug -- print(1,powers) puts(1,"\nChecking values\n") for i=3 to Number do -- For debug only -- print(1,i) -- puts(1,"\n") for j=1 to i-2 do for k=j+1 to i-1 do SquareSum=powers[j][2]+powers[k][2] CubicSum=powers[j][3]+powers[k][3] if SquareSum = powers[i][2] then printf(1,"Found a square sum %3d^2 = %3d^2 + %3d^2 \n",{i,j,k}) end if if CubicSum = powers[i][3] then printf(1,"Found a cubic sum %3d, %3d, %3d\n",{i,j,k}) puts (1, "Press Enter...") junk=gets(0) abort(1) end if end for end for -- Partial output, non stop comment this block if remainder(i,20)=0 then puts (1, "Press Enter... \n") junk=gets(0) end if -- End of partial output end for puts (1, "Appear that no cubic sum was found\n") puts (1, "Press Enter... ") junk=gets(0)