[Scilab-users] Loop query

Samuel Gougeon sgougeon at free.fr
Sun Aug 15 10:23:18 CEST 2021


Le 15/08/2021 à 09:00, Lester Anderson a écrit :
> Hello,
>
> Basic query. I have a simple code that applies the Collatz conjecture 
> equation (3n+1) by running a function and then runs a loop over the 
> values stored in prime (the first 8 Prime numbers):
>
> clear
> exec('collatz.sci',-1);
>
> prime  =  primes(20);
>
> for  i  =  1:length(prime)
>      [ns,  seq]=collatz(prime(i))
> end
> As it stands, this just runs to the end (i=8) and the value 19. How 
> can I get the code to write the results of each loop pass into the 
> variables ns and seq, such that each contains the results of the 8 passes?


This runs all the 8 iterations, but each next iteration overwrites ns 
and seq.
What are the sizes of ns and seq ?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20210815/bcc92ae7/attachment.htm>


More information about the users mailing list