prime package:real-dice
Module for finding the greatest prime number that is less than or
equal to a given number
Prime-length balanced binary string randomized with the RealDice raw
data
Prime-length balanced list of Bools randomized with the RealDice raw
data
Prime-length list of integers randomized with the RealDice raw data
Prime-length list of integers randomized with StdGen, for use as a
seed when generating the RealDice balanced data
This is raw random data from human interaction with the physical
world, truncated to have a prime number of elements
We provide a subset of the full data with a prime number of elements
so that it's less likely that a pattern will emerge when repeatedly
using a predictable algorithm to loop over the data
For example, suppose we have this random list of 12 elements:
"011010010011"
And suppose we repeatedly use a function that always references the
randomized list 4 times, each time using the element at the current
index and then incrementing the index by 1
In this scenario, the elements the function uses would start repeating
after running the function only three times
In contrast, if we use a subset of the list 11 items long
("01101001001"), we can run the function 11 times before the elements
start repeating
This is raw random data from human interaction with the physical
world, truncated to have a prime number of elements, and converted to
a list of Bools
Returns the greatest prime number that is not greater than the given
number
Returns 1 if called with the number 1
Returns 0 if called with a number lower than 1
See RealDice.Generate.RawData for reasons for use in this package
Examples
>>> greatestPrimeNotGreaterThan 10
7
>>> greatestPrimeNotGreaterThan 1024
1021
>>> greatestPrimeNotGreaterThan 1
1
>>> greatestPrimeNotGreaterThan 0
0
>>> greatestPrimeNotGreaterThan (-1024)
0