Some algorithms on stream
We have found that streams are infinite sequence. Hence, streams are used to create mathematical sequences. We find many mathematical series, which are used in day-to-day simulations and mathematical modeling. Some of mathematical series are as follows:
Arithmetic progression
Geometric progression
Harmonic progression
Fibonacci series
Brownian motion path
Let us explore some mathematical series using lazy sequences. I should start with the Arithmetic series.
Arithmetic progression
Arithmetic progression is a mathematical sequence where the difference between two consecutive elements is constant:
2, 5, 8, 11, 14, 17,...
The preceding mathematical sequence is an arithmetic progression, and the difference between any two consecutive elements is three. This constant difference is known as common difference. First term of the series is known as initial term. If 1 is the initial term of an arithmetic progression, then the nth term an is calculated as follows:
an = a1 + (n-1...