How to resolve the algorithm Pseudo-random numbers/Middle-square method step by step in the Arturo programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Pseudo-random numbers/Middle-square method step by step in the Arturo programming language

Table of Contents

Problem Statement

To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number in the sequence and returned as the result. This process is then repeated to generate more numbers. numbers (6 digits) as shown above.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Pseudo-random numbers/Middle-square method step by step in the Arturo programming language

Source code in the arturo programming language

seed: 675248

rand: function => [
    let 'seed <= ((seed^2) / 1000) % 1000000
]

do.times: 5 -> print rand


  

You may also check:How to resolve the algorithm Van Eck sequence step by step in the V (Vlang) programming language
You may also check:How to resolve the algorithm Benford's law step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Window creation step by step in the C# programming language
You may also check:How to resolve the algorithm Kolakoski sequence step by step in the C programming language
You may also check:How to resolve the algorithm Knapsack problem/Unbounded step by step in the SAS programming language