ReferenceselectPrimeNumbers

<selectPrimeNumbers/>

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

Attributes and Properties

Attributes for <selectPrimeNumbers>
AttributeTypeValues
asList = "…""true" "false"
exclude = "…"numberList
excludeCombinations = "…"
from = "…"integer
numToSelect = "…"integer
sort = "…"text"unsorted" "increasing" "decreasing" "true" "false"
to = "…"integer
withReplacement = "…"boolean"true" "false"
Props for <selectPrimeNumbers name="s">
PropertyType
$s.excludenumberList
$s.frominteger
$s.numToSelectinteger
$s.sorttext
$s.tointeger
$s.withReplacementboolean

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 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.


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.


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.