123456789101112131415161718192021222324 |
- #!/usr/bin/ruby
- # Author: Daniel "Trizen" Șuteu
- # License: GPLv3
- # Website: https://github.com/trizen
- # There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.
- # If the product of these four fractions is given in its lowest common terms, find the value of the denominator.
- # https://projecteuler.net/problem=33
- # Runtime: 0.147s
- var prod = 1
- [1..10, 1..10, 1..10].cartesian { |i,j,k|
- next if (i == j)
- if ((10*i + j) / (10*j + k) == i/k) {
- prod *= i/k
- }
- }
- say prod.de
|