How to resolve the algorithm Nth root step by step in the Raku programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Nth root step by step in the Raku 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 Raku programming language
Source code in the raku programming language
sub infix:<√>($n, $A) {
.tail given $A / $n, { (($n-1) * $_+ $A / ($_** ($n-1))) / $n } ... * ≅ *;
}
use Test;
plan 9;
is-approx ($_√pi)**$_, pi for 2 .. 10;
You may also check:How to resolve the algorithm String case step by step in the Elena programming language
You may also check:How to resolve the algorithm Compile-time calculation step by step in the zkl programming language
You may also check:How to resolve the algorithm Mutual recursion step by step in the Ol programming language
You may also check:How to resolve the algorithm First-class functions/Use numbers analogously step by step in the Sidef programming language
You may also check:How to resolve the algorithm Binary digits step by step in the Wren programming language