Skip to content

Instantly share code, notes, and snippets.

@ivyl
Created December 13, 2008 21:09
Show Gist options
  • Save ivyl/35545 to your computer and use it in GitHub Desktop.
Save ivyl/35545 to your computer and use it in GitHub Desktop.
#PI 1 + 1000 numbers
p -4*(0..10**9).inject{|r,e|r+(10**1000*(-1)**e/(2*e-1))}
#E 1 + 1000 numbers
p (1..10**3).inject(0){|r,e|r+(e==1?2:1)*(10**1000)/(1..e).inject{|r,e|r*e}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment