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-3 of 3 results.

A061364 Pseudo-random numbers: a (very weak) pseudo-random number generator from the second edition of the C book.

Original entry on oeis.org

16838, 5758, 10113, 17515, 31051, 5627, 23010, 7419, 16212, 4086, 2749, 12767, 9084, 12060, 32225, 17543, 25089, 21183, 25137, 25566, 26966, 4978, 20495, 10311, 11367, 30054, 17031, 13145, 19882, 25736, 30524, 28505, 28394
Offset: 0

Views

Author

Frank Ellermann, Jun 11 2001

Keywords

Comments

WATCOM C/C++ 10.0b uses this sequence for stdlib.h rand(). MS C 6.0 and gcc 2.6.3 use other (similar) sequences.

References

  • Brian W. Kernighan and Dennis M. Ritchie, The C Programming Language, Second Edition, ANSI C, 1988, Prentice-Hall Internat., ch. 2.7.
  • Brian W. Kernighan and Dennis M. Ritchie, The C-programming-language [German], 1990, Hanser, p. 45.

Crossrefs

A096554 is the same sequence seeded with 0.

Programs

  • C
    unsigned long next= 1; int i= 0; while (i++ < 33) next= next * 1103515245 + 12345, printf( "%d ", (unsigned)( next/65536 ) %32768 );
    
  • PARI
    x=1; m=2^32; for (n=0, 1000, x=(x*1103515245 + 12345)%m; write("b061364.txt", n, " ", (x\65536)%32768) ) \\ Harry J. Smith, Jul 21 2009

Formula

From David Fifield, May 23 2024: (Start)
a(n) = A096554(n+934703610).
a(n) = floor(A096553(n+2)/65536) mod 32768. (End)

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

Original entry on oeis.org

1546275796, 879788114, 1745191708, 771966234, 1247963869, 1611845387, 1529973242, 2093650929, 1860635684, 1497261229, 1145234796, 1165293667, 1233809453, 785019983, 252606271, 111721893, 473031201, 1002808953, 614474799, 471414712, 65507668
Offset: 1

Views

Author

Hugo Pfoertner, Sep 18 2016

Keywords

Comments

For comments, references and programs see A260083. Both the 32 bit and the 64 bit version of the random number generator have a period of 2^4096-1.

Crossrefs

Cf. A260083, 32 bit version of this random number generator.

Programs

  • PARI
    setrand(1); vector(100, i, random())

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-3 of 3 results.