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)
Alright, I forgot about this for a bit but here's half of the proof I was imagining:
Looking at just prime powers for now, let's take to be a self-equaling square modulo for prime and positive integer . can either be divisible by or not divisible by .
In the case that is divisible by (i.e. for some integer ), then . But must also be true, thus .
For the other case where is not divisible by , is necessarily coprime to . Thus, by Euler's totient theorem. As before, since must also be true, follows.
Therefore, every self-equaling square modulo a prime power must be congruent to either or . Or in other words, and are the only self-equaling squares modulo .
The other half is probably the easier part, some application of the Chinese remainder theorem should work. –PkmnQ (talk) 11:13, 23 May 2025 (UTC)