Fermat extended - Only for mathemathicians

new topic     » topic index » view thread      » older message » newer message

Dear EUphorians:
Apparently, someone proved the last theorem by Fermat to be true.
I don't know if the following extension to Fermat's theorem (or conjecture)
has ever be posed by someone, but here it is, with a program that tries to
find a counterexample. I've found no one yet.
Comments are welcome.

-- Trying to find a counterexample for the "extended-Fermat conjecture",
that
-- x[1]^p+x[2]^p...+x[n]^p = z^p, for x[i] > 0, 1 < n < p has no integer
-- solutions.
-- Author R. M. Forno - Version 1.0 - 2002/08/13

constant COMPL = 30 -- Start with numbers somewhat big
sequence top -- The elements

procedure verify(integer n, integer p) -- Verify conjecture
    atom root, sum
    integer r
    sum = 0
    for i = 1 to n do -- Always perform the sum to avoid rounding errors
        sum += power(top[i], p)
    end for
    root = power(sum, 1 / p)
    r = floor(root + 0.5) -- Beware of rounding errors
    if power(r, p) = sum then -- Show results... some day
        printf(1, "Power: %d Left: %f Right:", {p, root})
        for i = 1 to n do
            printf(1, " %d", top[i])
        end for
        puts(1, '\n')
    end if
end procedure

procedure fermat()
    integer p, k, i, r
    p = 2
    while p <= 20 do
        p += 1
        printf(1, "Testing exponent %d\n", p)
        r = p - 1
        for n = 2 to r - 1 do  -- Previous powers
            top = repeat(r + COMPL, r)
            verify (n, n + 1)
            i = n
            while i > 1 do
                while top[i] > 1 do
                    top[i] -= 1
                    k = top[i]
                    while i < n do
                        i += 1
                        top[i] = k  -- Avoid repeating previous tests
                    end while
                    verify(n, n + 1)
                end while
                i -= 1
            end while
        end for
        for n = 2 to r do -- Present power
            top = repeat(r + COMPL, r)
            verify (n, p)
            i = n
            while i do
                while top[i] > 1 do
                    top[i] -= 1
                    k = top[i]
                    while i < n do
                        i += 1
                        top[i] = k  -- Avoid repeating previous tests
                    end while
                    verify(n, p)
                end while
                i -= 1
            end while
        end for
    end while
end procedure

fermat()

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu