Skip to content

Instantly share code, notes, and snippets.

@dominictarr
Created September 10, 2010 11:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dominictarr/573462 to your computer and use it in GitHub Desktop.
calculate times table in base 12
begin
base = ARGV.length > 0 ? ARGV[0].to_i : 12
rescue
puts "usuage:
ruby #{__FILE__} {number}
(number = 12 by default)"
end
puts "times table in base #{base}:"
(base + 1).times {|x|
(base + 1).times {|y|
#print "#{(x*y).to_s(base)} "
printf "%3s ",(x*y).to_s(base)
}
print "\n"
}
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment