User talk:Aadenboy/Self-equaling squares

From Esolang
Jump to navigation Jump to search

Looking at things a bit closer, I think I can see a more specific pattern. The amount of self-equaling squares for a base seems to be , where is the number of unique prime factors has. For example, since , if the pattern is correct, it should only have self-equaling squares. I'll probably try to prove this later (a proof probably already exists somewhere but I think it'd be fun to try on my own). –PkmnQ (talk) 09:26, 11 May 2025 (UTC)

that's interesting! I wrote up a quick script to test this hypothesis and it does seem to hold true for the first 30k something numbers
local primes = require("primes") -- long list, highest is 1299827

function factorize(n)
    local hits = {}
    local unique = {}
    local current = n
    ::redo::
    for i=1, #primes do
        local prime = primes[i]
        if current % prime == 0 then
            current = current / prime
            if not hits[i] then table.insert(unique, prime) end
            hits[i] = (hits[i] or 0) + 1
            if current > 1 then goto redo else break end
        end
    end
    return hits, unique
end

for base=2, 100000 do -- arbitrary
    local digits = {}
    local _, target = factorize(base)
    for i=0, base-1 do
        if i^2 % base == i then
            table.insert(digits, i)
        end
    end
    print("Base "..base..": "..(2^#target == #digits and "PASS" or "FAIL")..". "..math.floor(2^#target).." expected, got "..#digits)
    if 2^#target ~= #digits then os.exit() end
end
aadenboy (talk|contribs) 17:17, 11 May 2025 (UTC)
completely forgot I had the program running in the background, all 100000 passed aadenboy (talk|contribs) 18:40, 11 May 2025 (UTC)