12345678910111213141516171819 |
- #!/usr/bin/ruby
- # Author: Daniel "Trizen" Șuteu
- # License: GPLv3
- # Website: https://github.com/trizen
- # By listing the set of reduced proper fractions for d ≤ 1,000,000 in ascending order of size, find the numerator of the fraction immediately to the left of 3/7.
- # https://projecteuler.net/problem=71
- # Runtime: 0.150s
- func before_numerator(b, n, d, m) {
- m -= (m+b % d)
- int(m/n + m/d - m/(n*d))
- }
- say before_numerator(2, 3, 7, 1e6)
|