answersLogoWhite

0

Let's assume that you want the sum of the general harmonic series:

sum(n=0,inf): 1/(an+b)

Since we know that the harmonic series will converge to infinity, we'll also assume that you want the sum from 0 to n.

double genHarmonic(const double n, const double a, const double b) {

double sum = 0.0;

// perform calculations

int k;

for(k = 0; k <= n; ++k) {

sum += 1.0 / (a * k + b);

}

return sum;

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Write a program to find the sum of sine series?

Writing a program for a sum of sine series requires a rather long formula. That formula is: #include #include #include main() { int i,n,x; .


Why is there no formula in getting the sum of a harmonic sequence?

A harmonic sequence is defined as a sequence of the form ( a_n = \frac{1}{n} ), where ( n ) is a positive integer. The sum of a harmonic series, ( \sum_{n=1}^{N} \frac{1}{n} ), diverges as ( N ) approaches infinity, meaning it grows without bound. Unlike arithmetic or geometric series, which have closed-form sums due to their consistent growth patterns, the harmonic series does not converge to a finite limit, making it impossible to express its sum with a simple formula. Thus, while there are approximations (like the use of logarithms), there is no exact formula for the sum of an infinite harmonic series.


What is the assembly program to generate a geometric series and compute its sum The inputs are the base root and the length of the series The outputs are the series elements and their sum?

What is the assembly program to generate a geometric series and compute its sum The inputs are the base root and the length of the series The outputs are the series elements and their sum?


How do you find the sum of nos in a series?

It depends on the series.


What is 1 plus 1 half plus 1 third plus 1 quarter plus 1 fifth and so on?

This series is known as the Harmonic Series and it diverges but very, very slowly. For example, the first 100 terms sum to 5.187...., the first 1000 terms to 7.486...., and the first 1000000 terms to 14.392.... There are many proofs of the divergence of this series and an internet search of Harmonic Series will no doubt find many of them.


How do you write an assembly language program to find the sum of n numbers using array?

write an assembly language program to find sum of N numbers


Write a program to find the sum of all positive number and terminate the program when sum exceed 999?

int sum = 0; int n = 0; while( sum &lt;= 999 ) { sum += (++n); }


Writes a c program to find the sum of all integers between 1 and n?

Write a program to find the number and sum of all integers from 100 to 300 that are divisible by 11


Java program to find sum on even numbers from 12-45?

sum = 0; for (int i = 12; i


Write a C program to find sum of 3 matrices?

matrix


How can you find the nth partial?

The Nth partial sum is the sum of the first n terms in an infinite series.


To find LCM of n numbers using 8085 programs?

sample program in sum of the series using the formula for s=n/2[2a+{n-1}d] in 8085