How to resolve the algorithm Arbitrary-precision integers (included) step by step in the CLU programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Arbitrary-precision integers (included) step by step in the CLU programming language
Table of Contents
Problem Statement
Using the in-built capabilities of your language, calculate the integer value of:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Arbitrary-precision integers (included) step by step in the CLU programming language
Source code in the clu programming language
start_up = proc ()
% Get bigint versions of 5, 4, 3 and 2
five: bigint := bigint$i2bi(5)
four: bigint := bigint$i2bi(4)
three: bigint := bigint$i2bi(3)
two: bigint := bigint$i2bi(2)
% Calculate 5**4**3**2
huge_no: bigint := five ** four ** three ** two
% Turn answer into string
huge_str: string := bigint$unparse(huge_no)
% Scan for first digit (the string will have some leading whitespace)
i: int := 1
while huge_str[i] = ' ' do i := i + 1 end
po: stream := stream$primary_output()
stream$putl(po, "First 20 digits: "
|| string$substr(huge_str, i, 20))
stream$putl(po, "Last 20 digits: "
|| string$substr(huge_str, string$size(huge_str)-19, 20))
stream$putl(po, "Amount of digits: "
|| int$unparse(string$size(huge_str) - i + 1))
end start_up
You may also check:How to resolve the algorithm Flatten a list step by step in the Prolog programming language
You may also check:How to resolve the algorithm Random number generator (included) step by step in the ZX Spectrum Basic programming language
You may also check:How to resolve the algorithm P-value correction step by step in the zkl programming language
You may also check:How to resolve the algorithm String case step by step in the Quackery programming language
You may also check:How to resolve the algorithm Walk a directory/Recursively step by step in the PicoLisp programming language