Determine the maximum value of a duodecimal (base 12) prime number N, such that none of the digits in the base 12 representation of N2 occur more than once.
clearvars,clc
largest=base2dec('ba9876543210',12);
p=prevprime(floor(sqrt(largest)));
while true
duo=dec2base(p^2,12);
if length(duo)==length(unique(duo))
disp(duo)
disp([p^2 p])
break
end
p=prevprime(p-1);
end
goes down the list of primes from sqrt(BA9876543210) to find
B7045936281 as the largest such square of a prime.
There is probably some divisibility rule in base-12 to prevent any 12-digit pandigital from being the square of a prime.
In decimal the found square is 717370038529, which is the square of 846977, which in base 12 is 34A195.
|
Posted by Charlie
on 2023-05-02 10:57:05 |