Scilab Home Page | Wiki | Bug Tracker | Forge | Mailing List Archives | Scilab Online Help | ATOMS
File : Details

isprime

calculates if a number is prime
(1764 downloads for this version - 1764 downloads for all versions)
Details
Version
1.0
Author
JFER GIRJ
Maintainer
JFER Girj
Category
License
Supported Scilab Version
5.4
Creation Date
April 14, 2012
Description
            Returns %T or %F 

Use:

isprime(arg).  arg is integer >=0            
Files (1)
[96 bytes]
Miscellaneous file
Returns 1 if true, 0 if not

Use:

isprime(arg).  arg is integer >=0



thanks to Allan CORNET for show me how to improve performance of this function
News (0)
Comments (2)
Comment from Allan Cornet -- April 14, 2012, 10:10:54 AM    
Hi,

A faster and easier way is:


function r = isprime(number)
  p = factor(number);
  r = (size(p, '*') == 1);
endfunction


Thanks

Allan
Comment from JFER Girj -- April 16, 2012, 06:55:33 PM    
thanks for the tip.  I'm new with scilab and i need to learn.  I appreciate your comment

JF