Funny code

  • Comments posted to this topic are about the item Funny code

  • Interesting question, thanks Steve

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • This is not only an interesting question but an implementation of an historically significant algorithm. Warning: it is also an extremely poorly behaved pseudo-random number generator.

    The algorithm is the middle-square PRNG due to John Non Neumann. To generate a sequence, one squares a four-digit seed and takes the middle four digits as the next element of the sequence. The while condition checks for the recurrence of an element.

    The algorithm generates notoriously short sequences. The longest has 111 elements. If an element under 100 occurs, the sequence collapse to 0. If a multiple of 100 occurs, the sequence will show up to 5 more multiples of 100 and then quit.

    Thanks for the interesting question, Steve

     

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply