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

classic Classic list List threaded Threaded
3 messages Options
Robin Seibel Robin Seibel
Reply | Threaded
Open this post in threaded view
|

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

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?

Thanks,

Robin

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Tim Wescott Tim Wescott
Reply | Threaded
Open this post in threaded view
|

Re: 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
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Klaus Rohe Klaus Rohe
Reply | Threaded
Open this post in threaded view
|

Re: New to Scilab and having issue with function I've written

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:[hidden email]] Im Auftrag von
[hidden email]
Gesendet: Samstag, 3. Januar 2015 06:51
An: [hidden email]
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
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users