Pseudo-random numbers/Middle-square method: Difference between revisions
Content added Content deleted
Jazzedpineda (talk | contribs) (Add EasyLang) |
Jazzedpineda (talk | contribs) (Replace Wikipedia link with template) |
||
Line 1: | Line 1: | ||
{{task}} |
{{task}} |
||
{{Wikipedia|Middle-square method|en}} |
|||
;[https://en.m.wikipedia.org/wiki/Middle-square_method Middle-square_method] Generator |
|||
; The Method: |
; The Method: |
||
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. |
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. |