Pseudo-random numbers/Middle-square method: Difference between revisions

Added Algol 68
No edit summary
(Added Algol 68)
Line 31:
* Show your output here, on this page.
 
 
=={{header|ALGOL 68}}==
Uses (long) integers.
<lang algol68>BEGIN # generate random numbers by the middle-square method #
INT seed := 675248;
# returns the next middle-square random number #
PROC ms random = INT: seed := SHORTEN( ( ( LONG INT( seed ) * LONG INT( seed ) ) OVER 1000 ) MOD 1 000 000 );
# test the ms random procedure #
FOR i TO 5 DO
print( ( whole( ms random, 0 ), newline ) )
OD
END</lang>
{{out}}
Same as the Python sample.
 
=={{header|FreeBASIC}}==
Line 51 ⟶ 65:
End Function
</lang>
 
=={{header|Phix}}==
You don't actually have to use strings, but should you so desire the commented-out line gives exactly the same results. Output matches Python.
3,026

edits