Created
April 3, 2017 21:36
-
-
Save hyuki0000/681d88bbdc643ee2c6935df4f5a1126a to your computer and use it in GitHub Desktop.
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
# 九九の表と倍数 | |
# https://twitter.com/hyuki/status/848895521846468608 | |
count = [] | |
(1..81).each do |n| | |
puts "n = #{n}" | |
count[n] = 0 | |
(1..9).each do |y| | |
(1..9).each do |x| | |
if x * y % n == 0 | |
print '■' | |
count[n] += 1 | |
else | |
print '□' | |
end | |
end | |
puts | |
end | |
puts | |
end | |
(1..81).each do |n| | |
printf("%2d の倍数は %2d 個\n", n, count[n]) | |
end |
Author
hyuki0000
commented
Apr 3, 2017
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment