Created
February 3, 2017 13:02
-
-
Save hyuki0000/d37e5398d08aff3c1dc38d348e00a52a to your computer and use it in GitHub Desktop.
Making A Babylonian-like Reciprocal Table (1..100)
This file contains hidden or 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
# Making A Babylonian-like Reciprocal Table (1..100) | |
# 1..100 の逆数表をバビロニア風に作る | |
# ただし、無限小数になるものは ... を付加する | |
# https://cakes.mu/posts/15267 | |
def inv60(n) | |
a = [] | |
m = 1 | |
loop do | |
x = (60 * m) / n | |
m = 60 * m - x * n | |
if a.include?(x) | |
a << '...' | |
break | |
end | |
a << x | |
break if m == 0 | |
end | |
puts "#{n} #{a.join(',')}" | |
end | |
(1..100).each do |n| | |
inv60(n) | |
end |
Author
hyuki0000
commented
Feb 3, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment