Created
December 11, 2011 16:37
-
-
Save buccolo/1461440 to your computer and use it in GitHub Desktop.
Computes OrdP values
This file contains 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
#!/usr/bin/ruby | |
if ARGV.length != 2 | |
print "syntax: ./Ord prime number\n" | |
exit | |
end | |
number = ARGV[1].to_f | |
number_print = ARGV[1].to_f | |
prime = ARGV[0].to_f | |
i = 0 | |
while ((number % prime == 0) and number != 0) | |
i = i + 1 | |
number = number / prime | |
end | |
print "Ord #{prime} (#{number_print}) = #{i}\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment