(Magma)
XOR := func<a, b | Seqint([ (adigs[i] + bdigs[i]) mod 2 : i in [1..n]], 2)
where adigs := Intseq(a, 2, n)
where bdigs := Intseq(b, 2, n)
where n := 1 + Ilog2(Max([a, b, 1]))>;
function IsClardynum(X, i)
if i eq 1 then
return true;
else
xornum:=2^i - 2;
xorcouple:=XOR(X, xornum);
if (IsPrime(xorcouple)) then
return false;
else
return IsClardynum(X, i-1);
end if;
end if;
end function;
function Korselt(X, n);
i:=1;
while IsDefined(X, i) do
b:=(n-1)mod(X[i]-1);
if (b ne 0) then return false;
else i:=i+1;
end if;
end while;
return true;
end function;
function IsCarmichael(n);
if IsPrime(n) then return false;
end if;
A:=AssociativeArray();
if IsSquarefree(n) then
A:=PrimeDivisors(n);
if Korselt(A, n) then return true;
else return false;
end if;
else
return false;
end if;
end function;
for i:=561 to 100000001 by 2 do
if IsCarmichael(i) then
if IsClardynum(i, Ilog2(i)) then i;
end if;
end if;
end for;
|