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.

Showing 1-2 of 2 results.

A260083 Consecutive numbers generated by the 'random' function in PARI (32 bit, version > 2.4) using the default argument (2^31).

Original entry on oeis.org

326511477, 1362174608, 903267448, 656347688, 1853455872, 693790135, 1743812782, 1381849689, 1919384312, 561030593, 610902088, 1730365257, 1381380589, 1437333698, 1880143150, 1861285526, 135271255, 2062787134, 476812016, 748713098, 702275007, 1351923632
Offset: 1

Views

Author

Felix Fröhlich, Jul 15 2015

Keywords

Comments

These are the values the function generates in PARI/GP v 2.7.0, using Richard Brent's XORGEN algorithm.
For all n, 0 < a(n) < 2^31.
All 32-bit PARI versions > 2.4 should yield this sequence of pseudo-random numbers, when the random generator is in its initial state or reset to that state using setrand(1). - M. F. Hasler, Sep 18 2016
The generator has a period of 2^4096-1. - Hugo Pfoertner, Sep 18 2016

Crossrefs

Cf. A276820: Corresponding 64 bit random number generator.

Programs

  • PARI
    a(n) = random \\ Works only if called first with n=1, then with n=2, etc, and if the internal random generator was never called before or reset via setrand(1)
    
  • PARI
    setrand(1); A260083=vector(100,i,random()) \\ M. F. Hasler, Sep 18 2016

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

Original entry on oeis.org

1, 149, 11249, 57305, 38044, 35283, 24819, 26463, 18689, 25472, 9901, 21742, 57836, 12332, 7456, 34978, 1944, 14800, 61482, 23634, 3125, 37838, 19833, 45735, 22275, 32274, 61292, 9384, 48504, 33339, 10093, 36142, 23707, 8600, 55241, 14318, 25332, 64938, 20686, 44173, 36199, 27982
Offset: 1

Views

Author

Jacques Basaldúa, Oct 19 2022

Keywords

Comments

The ZX81 had a congruential random number generator with the hardcoded values: x <- (75*x + 74) mod 65537.
This sequence starts with x = 1. The ZX81 had the option to start with a hardware counter.
The sequence has period 2^16. - Rémy Sigrist, Oct 20 2022
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

Crossrefs

Programs

  • Mathematica
    NestList[Mod[75*# + 74, 65537] &, 1, 50] (* Paolo Xausa, Oct 03 2024 *)
  • PARI
    my(c=Mod(75,65537)); a(n) = lift(2*c^(n-1) - 1); \\ Kevin Ryde, Oct 22 2022
    
  • Python
    def a(n): return (2*pow(75, n-1, 65537) - 1)%65537
    print([a(n) for n in range(1, 43)]) # Michael S. Branicky, Oct 23 2022
  • R
    x <- 1
    nxt <- function(x) (75*x + 74) %% 65537
    for (t in 1:1000) {
      cat(sprintf('%i, ', x))
      x <- nxt(x)
    }
    

Formula

a(n) = (75*a(n-1) + 74) mod 65537, a(1) = 1.
a(n + 2^16) = a(n). - Rémy Sigrist, Oct 20 2022
a(n) = (2*75^(n-1) - 1) mod 65537. - Kevin Ryde, Oct 20 2022
a(n) = a(n-1) - a(n-32768) + a(n-32769) for n > 32769. - Ray Chandler, Aug 03 2023
Showing 1-2 of 2 results.