cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A357907 The internal state of the Sinclair ZX81 and Spectrum random number generator.

This page as a plain text file.
%I A357907 #53 Jun 14 2025 18:36:58
%S A357907 1,149,11249,57305,38044,35283,24819,26463,18689,25472,9901,21742,
%T A357907 57836,12332,7456,34978,1944,14800,61482,23634,3125,37838,19833,45735,
%U A357907 22275,32274,61292,9384,48504,33339,10093,36142,23707,8600,55241,14318,25332,64938,20686,44173,36199,27982
%N A357907 The internal state of the Sinclair ZX81 and Spectrum random number generator.
%C A357907 The ZX81 had a congruential random number generator with the hardcoded values: x <- (75*x + 74) mod 65537.
%C A357907 This sequence starts with x = 1. The ZX81 had the option to start with a hardware counter.
%C A357907 The sequence has period 2^16. - _Rémy Sigrist_, Oct 20 2022
%C A357907 The ZX81 returned these values divided by 65536 as floating-point numbers, however, the seed was set as an integer using RAND (or RANDOMIZE on the ZX Spectrum). To produce the sequence as given here on the ZX81, set the seed with RAND 25340 (the last value in the period before it returns to 1), then print successive values with PRINT 65536*RND. On the ZX81, the current seed was stored in memory locations 16343 and 16384, and could be retrieved with PRINT 256*PEEK 16435+PEEK 16434 (which is equivalent to PRINT 65536*RND, but does not trigger stepping to the next value). - _Sean A. Irvine_, May 08 2025
%H A357907 Jianing Song, <a href="/A357907/b357907.txt">Table of n, a(n) for n = 1..65536</a>
%H A357907 B. D. Ripley, <a href="https://doi.org/10.2307/1402590">Computer Generation of Random Variables: A Tutorial</a>, International Statistical Review, 51 (1983), 301-309.
%H A357907 W. E. Sharp and Carter Bays, <a href="https://doi.org/10.1016/0098-3004(92)90060-5">A review of portable random number generators</a>, Computers and Geosciences, 18, 1 (1982), 79-87.
%H A357907 Wikipedia, <a href="https://en.wikipedia.org/wiki/Linear_congruential_generator">Linear congruential generator</a>.
%H A357907 <a href="/index/Rec#order_32769">Index entries for linear recurrences with constant coefficients</a>, order 32769.
%H A357907 <a href="/index/Ps#PRN">Index entries for sequences related to pseudo-random numbers</a>.
%F A357907 a(n) = (75*a(n-1) + 74) mod 65537, a(1) = 1.
%F A357907 a(n + 2^16) = a(n). - _Rémy Sigrist_, Oct 20 2022
%F A357907 a(n) = (2*75^(n-1) - 1) mod 65537. - _Kevin Ryde_, Oct 20 2022
%F A357907 a(n) = a(n-1) - a(n-32768) + a(n-32769) for n > 32769. - _Ray Chandler_, Aug 03 2023
%t A357907 NestList[Mod[75*# + 74, 65537] &, 1, 50] (* _Paolo Xausa_, Oct 03 2024 *)
%o A357907 (R)
%o A357907 x <- 1
%o A357907 nxt <- function(x) (75*x + 74) %% 65537
%o A357907 for (t in 1:1000) {
%o A357907   cat(sprintf('%i, ', x))
%o A357907   x <- nxt(x)
%o A357907 }
%o A357907 (PARI) my(c=Mod(75,65537)); a(n) = lift(2*c^(n-1) - 1); \\ _Kevin Ryde_, Oct 22 2022
%o A357907 (Python)
%o A357907 def a(n): return (2*pow(75, n-1, 65537) - 1)%65537
%o A357907 print([a(n) for n in range(1, 43)]) # _Michael S. Branicky_, Oct 23 2022
%Y A357907 Cf. A061364, A096550-A096561, A260083, A276820.
%K A357907 nonn,easy
%O A357907 1,2
%A A357907 _Jacques Basaldúa_, Oct 19 2022