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

isprime

calculates if a number is prime
(1962 downloads for this version - 1962 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)     Leave a comment 
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
Leave a comment
You must register and log in before leaving a comment.
Login with GitLab
Email notifications
Send me email when this toolbox has changes, new files or a new release.
You must register and log in before setting up notifications.