Loading ...
Sorry, an error occurred while loading the content.

Re: slow method for the order of 2

Expand Messages
  • djbroadhurst
    ... Not so. This was my encoding of your ultra-slow method: ord(n)=local(m=n,c);while(m,c++;m=(m+if(m%2,0,n)-1)/2);c; Let s add some print statements:
    Message 1 of 2 , Jun 3, 2010
    • 0 Attachment
      --- In primenumbers@yahoogroups.com,
      "rach" <maths_forall@...> wrote:

      > but differences between these two methods

      Not so. This was my encoding of your ultra-slow method:

      ord(n)=local(m=n,c);while(m,c++;m=(m+if(m%2,0,n)-1)/2);c;

      Let's add some print statements:

      {ord2(n)=local(m=n,c);
      while(m,c++;print1(m" ");m=(m+if(m%2,0,n)-1)/2);
      print(": order of 2 modulo "n" = "c);c;}

      Then, with n=23, we obtain:

      ord2(23);
      23 11 5 2 12 17 8 15 7 3 1 : order of 2 modulo 23 = 11

      which is /precisely/ your ultra-slow method.

      David
    Your message has been successfully submitted and would be delivered to recipients shortly.