Primes are positive integers that can only be divided by 1 and themselves. Here's a very simple prime checker, which returns 1 for primes, else the first found divisor (and the quotient): proc primetest n { set max [expr wide(sqrt($n))] if {$n%2==0} {return [list 2 [expr $n/2]]} for {set i 3} {$i<=$max} {incr i 2} { if {$n%$i==0} {return [list $i [expr $n/$i]]} } return 1 } [AM] commented in the [Tcl chatroom]: "The trick: divide by the first ten or twenty primes, after that: numbers of the form 6n+1 and 6n+5 may act as divisors. If you use only numbers of the form I mentioned, you gain about 50% with no loss of information." ---- [Category Concept] | [Arts and crafts of Tcl-Tk programming]