Posted by inv.rb on Tue 29 Nov 2011 5:53:42 CET
download |
new post
#!/usr/bin/env ruby def inverse_class(class_, width) found = false 0.upto(width-1){|i| res = (class_ * i) % width if res == 1 || res == width-1 then print "Inverzni prvek k [", class_, "]_", width, " je [", i, "]_", width, ".\n" found = true break end } print "Inverzni prvek k [", class_, "]_", width, " neexistuje.\n" if found == false end