Returns the partial sum of the geometric sequence. i.e. 1 + r + r^2 + r^3 + ... + r^n
npm install partial-geometric-series
/*
Return the partial sum of a geomtric series
*/
var p = require('partial-geometric-series');
var ratio = 0.3 // Must be <1 for convergence
var nth = 5 // nth partial sum
console.log( 'Partial Sum:', p(ratio, nth) ) // Partial Sum: 1.42753
console.log( 'Infinite Sum:', 1/(1-0.3)) // Infinite Sum: 1.4285714285714286
MIT