Primitive root of 13

used ETF and gcd

You are now following this Submission

P = ETF(13);
Q = ETF(P);
fprintf("Total roots: %d", Q);
fprintf("\n");
One = mod(2.^12,13);
fprintf("Since 2 to power 12 modular 13 equal to %d, 2 is a primitive root of 13. \n",One);
fprintf("The primitive roots of 13: ");
A = [];
for i = 1:12
d = gcd(i,12);
if(d==1)
result = mod(2.^i,13);
A(end+1) = result;
end
end
A = sort(A);
fprintf("%g ",A);
function res = ETF(N)
S = 1;
for i = 1:N
x = mod(N,i);
if(x==0)
y = isprime(i);
end
if(y==1)
S = S.*(1-1./i);
end
end
res = N.*S;
end
function res = gcd(m,n)
while true
remainder = mod(n,m);
if(remainder == 0)
res = m;
break;
end
n = m;
m = remainder;
end
end

Cite As

Hoi Sing Lau (2026). Primitive root of 13 (https://in.mathworks.com/matlabcentral/fileexchange/184169-primitive-root-of-13), MATLAB Central File Exchange. Retrieved .

Acknowledgements

Inspired by: Primitive Root Function w/ Euler's Totient

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0