Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created August 6, 2014 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpodwysocki/f76d9843bc3f862da3e7 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/f76d9843bc3f862da3e7 to your computer and use it in GitHub Desktop.
function pi(k) {
return ( k % 2 === 0 ? -4 : 4) / (( 2 * k ) - 1 );
}
var total = Rx.Observable.range(1, 10000000, Rx.Scheduler.timeout)
.map(pi)
.sum();
total.subscribe(function (x) { console.log(x); });
//=> 3.1415925535897915
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment