How to resolve the algorithm Pseudo-random numbers/Middle-square method step by step in the VBA 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 VBA 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: