Skip to main content
7 of 7
Commonmark migration

Ruby, 122 77 65 bytes

Thanks to Sherlock for shaving off 10 bytes.

require'prime'
->n{Prime.take(n).map{|x|1-2r/(x*x+1)}.reduce(:*)}

Defines an anonymous function that takes a number and returns a Rational.

a spaghetto
  • 11.3k
  • 3
  • 46
  • 82