Skip to content

Instantly share code, notes, and snippets.

@mame mame/gist:6828520
Created Oct 4, 2013

What would you like to do?
# 0 < A < B < 1 を仮定
lower, upper = 0, 1
loop do
m = Rational(lower.numerator + upper.numerator, lower.denominator + upper.denominator)
when m < A then lower = m
when B < m then upper = m
else p [:found, m]; exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.