Skip to Content
ReferenceselectPrimeNumbers

<selectPrimeNumbers/>

Randomly selects prime numbers from a range to create document variants

<selectPrimeNumbers/> is a Math component that selects prime numbers at random from a specified range. Selections generate variants of the document.

Attributes and Properties

Attributes for <selectPrimeNumbers>

Number display (5)
avoidScientificNotationIn development

boolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.

displayDecimalsIn development

integer. Default value: 2. Number of decimal places to display when rendering this number.

displayDigitsIn development

integer. Default value: 3. Number of significant digits to display when rendering this number.

displaySmallAsZeroIn development

number. Default value: 1e-14. Threshold below which numbers are displayed as zero.

padZerosIn development

boolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Other (8)
asList

boolean. Default value: true. Whether to render the items separated by commas (true) or with no separator (false).

numberList. Primes to exclude from the selection.

_listOfNumberLists. Combinations of values that should not be selected together.

fromAdded in 0.7.13

integer. Default value: 2. Lower bound (inclusive) of the prime range to select from.

numToSelect

integer. Default value: 1. How many prime numbers to select.

sortAdded in 0.7.14

keyword. Sort order applied to the selected primes.

ValueDescription
unsorted (default)Preserve the random selection order.
increasingSort the selected primes in increasing order.
decreasingSort the selected primes in decreasing order.
toAdded in 0.7.13

integer. Default value: 100. Upper bound (inclusive) of the prime range to select from.

boolean. Default value: false. Whether the same prime can be selected more than once.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <selectPrimeNumbers name="s">

Number display (5)
$s.avoidScientificNotationIn development

boolean. Whether to render numbers in full decimal form rather than scientific notation.

$s.displayDecimalsIn development

integer. Number of decimal places to display when rendering this number.

$s.displayDigitsIn development

integer. Number of significant digits to display when rendering this number.

$s.displaySmallAsZeroIn development

number. Threshold below which numbers are displayed as zero.

$s.padZerosIn development

boolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Other (6)
$s.exclude

numberList. Primes to exclude from the selection.

$s.fromAdded in 0.7.13

integer. Lower bound (inclusive) of the prime range to select from.

$s.numToSelect

integer. How many prime numbers to select.

$s.sortAdded in 0.7.14

text. Sort order applied to the selected primes.

$s.toAdded in 0.7.13

integer. Upper bound (inclusive) of the prime range to select from.

$s.withReplacement

boolean. Whether the same prime can be selected more than once.

Common to all components (8)
$s.disabledIn development

boolean. Whether this component is disabled and cannot be interacted with.

$s.doenetML

text. The DoenetML source code that produced this component.

$s.fixedIn development

boolean. Whether this component's value is fixed and cannot be modified.

$s.fixLocationIn development

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$s.hiddenIn development

boolean. Whether this component is hidden from the rendered output.

$s.hide

boolean. Whether to hide this component from the rendered output.

$s.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$s.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Default <selectPrimeNumbers/>

The default <selectPrimeNumbers/> has a sequence range from 22 to 9797.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Example: Generate multiple selections

Three numbers that are selected between 22 and 5050. Individual selections can be accessed using array notation.


Example: Assigning descriptive names to multiple selections

The numToSelect attribute allows for selection of multiple values within the range of a single <selectPrimeNumbers/> component. Multiple selections are made without replacement. Selections can be assigned more descriptive names by defining individual components which reference the selected values.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.

Attribute Examples

Attribute Example: sort

The sort attribute determines how selected results are sorted. It accepts three values:

  • "unsorted" (default) - results are in the order they were selected
  • "increasing" - results are sorted in increasing order
  • "decreasing" - results are sorted in decreasing order

Alternatively, sort and sort="true" are equivalent to sort="increasing", and sort="false" is equivalent to sort="unsorted".

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: from, to

The from and to attributes specify the endpoints of the selection interval. These endpoints are not required to be prime numbers.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: exclude

The exclude attribute specifies values to exclude in the selection. Doenet will throw an error if sufficient primes are not available in the selection interval without replacement. If repetitions are allowed, the withReplacement attribute can be used.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: withReplacement

If selection with replacement is the desired behavior, use the withReplacement attribute.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: excludeCombinations

The excludeCombinations attribute can be used to exclude undesired combinations of prime numbers.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.

Last updated on