How to resolve the algorithm Calculating the value of e step by step in the langur programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Calculating the value of e step by step in the langur programming language

Table of Contents

Problem Statement

Calculate the value of   e.

(e   is also known as   Euler's number   and   Napier's constant.)

See details: Calculating the value of e

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Calculating the value of e step by step in the langur programming language

Source code in the langur programming language

mode divMaxScale = 104

val .epsilon = 1.0e-104

var .e = 2

for .fact, .n = 1, 2 ; ; .n += 1 {
    val .e0 = .e
    .fact x= .n
    .e += 1 / .fact
    if abs(.e - .e0) < .epsilon: break
}

writeln ".e = ", .e

# compare to built-in constant e
writeln " e = ", e

  

You may also check:How to resolve the algorithm Sequence of non-squares step by step in the GAP programming language
You may also check:How to resolve the algorithm Bitmap step by step in the Julia programming language
You may also check:How to resolve the algorithm Monads/Maybe monad step by step in the J programming language
You may also check:How to resolve the algorithm Stirling numbers of the first kind step by step in the ALGOL W programming language
You may also check:How to resolve the algorithm Cartesian product of two or more lists step by step in the jq programming language