Category: Tail Recursion
-
Continued Fraction Tail Recursive
An infinite continued fraction is an expression of the form The infinite continued fraction expansion with the Ni and the Di all equal to 1 produces 1/, where is the golden ratio. One way to approximate an infinite continued fraction is to truncate the expansion after a given number of terms. Such a truncation —…
-
Multiplication by Successive Doubling
Implementation of a tail recursive algorithm for multiplication by means of repeated addition (doubling). This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters…
-
Exponentiation by successive squaring
Implementation of a procedure that evolves an iterative exponentiation process that uses successive squaring and uses a logarithmic number of steps. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more…