How to resolve the algorithm Harmonic series step by step in the Maxima programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Harmonic series step by step in the Maxima programming language
Table of Contents
Problem Statement
In mathematics, the n-th harmonic number is the sum of the reciprocals of the first n natural numbers: The series of harmonic numbers thus obtained is often loosely referred to as the harmonic series. Harmonic numbers are closely related to the Riemann zeta function, and roughly approximate the natural logarithm function; differing by γ (lowercase Gamma), the Euler–Mascheroni constant. The harmonic series is divergent, albeit quite slowly, and grows toward infinity.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Harmonic series step by step in the Maxima programming language
Source code in the maxima programming language
harmonic(n):=apply("+",1/makelist(i,i,n))$
first_greater_than_n(len):=block(i:1,result:[],while harmonic(i)<=len do (result:endcons(i,result),i:i+1),last(result)+1)$
/* Test cases */
/* First 20 harmonic numbers */
makelist(harmonic(j),j,20);
/* First harmonic number that exceeds a positive integer from 1 to 5 */
makelist(first_greater_than_n(k),k,5);
You may also check:How to resolve the algorithm Accumulator factory step by step in the Nim programming language
You may also check:How to resolve the algorithm Sudan function step by step in the Draco programming language
You may also check:How to resolve the algorithm Brazilian numbers step by step in the AppleScript programming language
You may also check:How to resolve the algorithm Parameterized SQL statement step by step in the BASIC programming language
You may also check:How to resolve the algorithm Luhn test of credit card numbers step by step in the Wren programming language