f::prime_p (public)
f::prime_p n
Defined in packages/acs-tcl/tcl/ad-functional-procs.tcl
Example: f::filter f::prime_p [f::enum_from_to 1 100] = {2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97}
- Parameters:
- n (required)
- Returns:
- boolean, 1 if n is prime
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- functional_api
Source code: if { $n<2 } { return 0 } if { $n==2 } { return 1 } if { [even_p $n] } { return 0 } for {set i 3} {$i*$i<=$n} {incr i 2} { if { $n%$i==0 } { return 0 } } return 1XQL Not present: Generic, PostgreSQL, Oracle