How to resolve the algorithm Nth root step by step in the HicEst programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Nth root step by step in the HicEst programming language

Table of Contents

Problem Statement

Implement the algorithm to compute the principal   nth   root

A

n

{\displaystyle {\sqrt[{n}]{A}}}

of a positive real number   A,   as explained at the   Wikipedia page.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Nth root step by step in the HicEst programming language

Source code in the hicest programming language

WRITE(Messagebox) NthRoot(5, 34)
WRITE(Messagebox) NthRoot(10, 7131.5^10)

FUNCTION NthRoot(n, A)
   REAL :: prec = 0.001

   IF( (n > 0) * (A > 0) ) THEN
       NthRoot = A / n
       DO i = 1, 1/prec
         x = ((n-1)*NthRoot + A/(NthRoot^(n-1))) / n
         IF( ABS(x - NthRoot) <= prec ) THEN
             RETURN
         ENDIF
         NthRoot = x
       ENDDO
   ENDIF

   WRITE(Messagebox, Name) 'Cannot solve problem for:', prec, n, A
END

  

You may also check:How to resolve the algorithm Loops/For step by step in the Morfa programming language
You may also check:How to resolve the algorithm Minesweeper game step by step in the BASIC programming language
You may also check:How to resolve the algorithm Sorting algorithms/Bubble sort step by step in the Arendelle programming language
You may also check:How to resolve the algorithm Balanced ternary step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Fibonacci n-step number sequences step by step in the Tailspin programming language