Routine Summary

Calculates the mode(s) of a list of numbers.


L₁ - To store the user-inputted list of numbers


L₃ - The mode(s) of the original list of numbers
Ans - The mode(s) of the original list of numbers (alternates)

Variables Used

L₂ - Intermediate calculation storage
X - Weregoose's version only

Calculator Compatibility



kg583, Trenly, Weregoose

:ClrList L₂,L₃
:If not(max(L₁(L)=imag(L₂
:If real(L₂(L))=max(real(L₂

The mode of a list is the value that occurs most often within the list. This routine will find the mode and, if there are any ties, will display all modes. Examples:

Mode = {3}
Mode = {5,6}

Alternate Routines

:Repeat min(0≠ΔList(L₂
:If not(L₃(θ

This version coded by Trenly is slightly shorter than the above routine by kg583 and produces the same output, which is saved in Ans rather than L₃. However, the original list in L₁ is modified in the process, so make sure to backup that list somewhere else if you need it later.

:While max(Ans
:sum(L₁ xor 0→dim(L₁

This version written by Weregoose is very similar to Trenly's in form and function. The output is, again, in Ans and lists all modes, but does also modify L₁ in the process. Note the advanced use of the xor function.


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.