SIGN IN SIGN UP

Algorithms and Data Structures implemented in JavaScript for beginners, following best practices.

34083 0 0 JavaScript
2021-10-23 23:14:01 +05:30
import { sumOfGeometricProgression } from '../SumOfGeometricProgression'
describe('Sum Of Geometric Progression', () => {
it('should return the sum of a finite GP', () => {
expect(sumOfGeometricProgression(100, 1.5, 4)).toBe(812.5)
})
it('should return the sum of an infinite GP', () => {
expect(sumOfGeometricProgression(2, 0.5, Infinity)).toBe(4)
})
it('should throw when series diverges', () => {
expect(() => sumOfGeometricProgression(1, 1, Infinity)).toThrowError()
})
2021-10-23 23:14:01 +05:30
})