072 Counting fractions.sf 289 B

1234567891011121314151617
  1. #!/usr/bin/ruby
  2. # Author: Daniel "Trizen" Șuteu
  3. # Date: 15 August 2016
  4. # License: GPLv3
  5. # Website: https://github.com/trizen
  6. # https://projecteuler.net/problem=72
  7. # Runtime: 3.661s (previously 5.425s)
  8. func count_frac(n) {
  9. sum(2..n, {|k| euler_totient(k) })
  10. }
  11. say count_frac(1e6)