Skip to content

Commit

Permalink
Add tst/modulor.rb for gh-76
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Sep 14, 2022
1 parent 6bf1686 commit 980f4a5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tst/modulo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

def show(mod0, mod1)

puts "%#{mod0}+#{mod1}"
(mod0 + 1).times do |i|
print "%3d: " % [
i ]
print "%d %% %d --> %d" % [
i, mod0, i % mod0 ]
print " | %d %% %d == %d --> %5s" % [
i, mod0, i % mod0, (i % mod0) == mod1 ]
print " | (%d + %d) %% %d == 0 --> %5s" % [
i, mod0, mod1, (i + mod1) % mod0 == 0 ]
print " | %d %% %d == %d %% %d --> %5s" % [
i, mod0, mod1, mod0, i % mod0 == mod1 % mod0 ]
puts
end
end

puts; show(2, 1)
puts; show(3, 2)
puts; show(2, 2)
puts; show(2, 4)
puts; show(4, 3)

0 comments on commit 980f4a5

Please sign in to comment.