130 Composites with prime repunit property.sf 358 B

12345678910111213141516
  1. #!/usr/bin/ruby
  2. # Daniel "Trizen" Șuteu
  3. # Date: 21 September 2019
  4. # Edit: 30 March 2023
  5. # https://github.com/trizen
  6. # https://projecteuler.net/problem=130
  7. # Runtime: 0.516s
  8. 2..Inf -> lazy.grep {|n| n.is_composite }\
  9. .grep {|n| n.is_coprime(10) }\
  10. .grep {|n| (Mod(10, n)**(n-1) - 1)/9 == 0 }\
  11. .first(25).sum.say