[R] translate octave code to R

bertola_br (YAHOO!) bertola_br at yahoo.com
Sun Mar 17 22:40:20 CET 2002


Hello,

I'd like to translate de code below, write in octave, to R. I'm learning to
operate R a few time ago, and an example of translation will be useful for
me.
This code is my lectures in an undergraduate course of statistical
computing.



echo off;
k=0;
while (k<>1)
  n = input('a prime: ');
  D = 2;
  r = n - D * floor((n/D));
  while((D <= sqrt(n) & (r <> 0)))
    D=D+1;
    r = n - D * floor((n/D));
  endwhile;
  if ((n - D * floor((n/D))) <> 0)
    disp('É primo');
    k=1;
  else
    disp('try again');
  end;
end;


#start of pseudo-random numbers generation

m = 2**35;
a = (2**7)+3;
c = a;
x(1)=n;#seed
u(1)=0;
i=1;
while (i<=500)

  x(i+1)=((a*x(i)+c) - (m*floor(((a*x(i)+c)/m))));
  u(i)=(x(i+1)/m);
  i++;

endwhile;
hist(u);



Thank you for attention,

Rafael Bertola
(UNICAMP (University of Campinas) - Brasil)





_________________________________________________________



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list