Created
April 13, 2011 01:25
-
-
Save Maffsie/916792 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prim = 1006715300258737517153797977627554475277170337033425229178637260151832787250683123774974903059149148740885836046105876842636196994953312702038908731078687604294151667710493949905267104133001418706162230966564070651880821344281694507024120672032445647737187539448358803929763339505148604908023222920128740659238180776381141651534114837389323369220973374958596158128235419159167760138076444579661180723 | |
o = 1 | |
roots = Array.new | |
z = 0 | |
r = 2 | |
until r >= prim do | |
k = r ** o | |
k %= prim | |
while k > 1 do | |
o += 1 | |
k *= r | |
k %= prim | |
end | |
if o == (prim - 1) | |
roots[z] = r | |
z += 1 | |
end | |
o = 1 | |
r += 1 | |
end | |
puts prim + " has " + z + " primitive roots: \n" | |
z -= 1 | |
y = 0 | |
while y < z do | |
puts roots[y] + "\n" | |
y += 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment