[Scilab-users] New to Scilab and having issue with function I've written

Klaus Rohe klaus-rohe at t-online.de
Sat Jan 3 11:52:44 CET 2015


Hi,

the following function works fine (Scilab 5.5.1):

-->function [x]=isprime(num)
-->    vect=factor(num);
-->    if length(vect) == 1 then
-->        x=1;
-->    else
-->        x=0;
-->    end
-->endfunction
 
-->isprime(37)
 ans  =
 
    1.  
 
-->isprime(36)
 ans  =
 
    0.  

Kind regards

Klaus

-----Ursprüngliche Nachricht-----
Von: users [mailto:users-bounces at lists.scilab.org] Im Auftrag von
tim at wescottdesign.com
Gesendet: Samstag, 3. Januar 2015 06:51
An: users at lists.scilab.org
Betreff: Re: [Scilab-users] New to Scilab and having issue with function
I've written

On 2015-01-02 20:47, Robin Seibel wrote:
> I wrote the following function:
> 
> function [x]=isprime(num)
>  vect=factor(num);
>  if length(vect)==1 then
>  x=1;
>  else
>  x=0;
>  end
> 
> endfunction
> 
> I am getting the following output:
> 
> -->isprime(25411588)
> 
>  0.
>  ans =
> 
>  0.
> 
> Why am I getting output twice, or in other words how can I suppress 
> the first zero reported in the command window?
> 

Hey Robin:

I just tried this, and I'm not getting that behavior.  In over a decade of
using Scilab, I haven't seen that behavior.  So I'm not good for much help.

Two things that you can try, however, are:

1: If you haven't yet, try it again, in case the Evil Computer Gods have
been messing with your head.  Maybe close Scilab and open it again.

2: Tell us what Scilab version you're using, as well as what OS.  For your
Scilab version, type getversion (e.g. mine is Scilab-5.5.1).  This won't
help me help you, but it may help someone smarter than me help you.
_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users




More information about the users mailing list