Last active
September 7, 2018 10:42
-
-
Save veelenga/754789e02a64cb5c5cd85d83bdcb96c1 to your computer and use it in GitHub Desktop.
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
require "big/big_rational" | |
def root(n, acc = BigRational.new(2)) | |
base = ->(n : BigRational) { 2 + n.inv } | |
n.times { acc = base.call(acc) } | |
1 + acc.inv | |
end | |
puts (1..999).map { |n| root(n) }.map { |r| [r.numerator.digits.size, r.denominator.digits.size] }.count { |(n, d)| n > d } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment