30.12.16

Just another sequence

In my previous post I talked about the order of 2 mod n where n is an integer such that either n = 2^i + (2^(i-1) - 3) when i is even or n = 2^i + (2^(i-1) + 3) when i is odd.

I conjectured that the order of 2 mod n for such n is i + (i - 2) regardless of whether i is even or odd.

The recurrence relation for generating all such n up to a limit is :

2i + (2(i-1) - 3) if i is even
or 2i + (2i-1 + 3) if i is odd

For the fun of it, I wrote a simple script to generate the first few such integers up to some limit.

/* -------------------------------------------------  
 This content is released under the GNU License  
 http://www.gnu.org/copyleft/gpl.html 
 Author: Marina Ibrishimova 
 Version: 1.0
 Purpose: Generate the 3sequence  
  
 ---------------------------------------------------- */  
function gen_seq(i, limit, a)
{
 var j = i - 1;
 var n = Math.pow(2,j);
 var m = Math.pow(2,i);
 if (i < limit)
 {
  if (i % 2 != 0)
  {
   n = n + 3;
  }
  else
  {
   n = n - 3;
  }
  a.push(m+n);
  i = i + 1;
  gen_seq(i, limit, a)  
 }
 return a;
}

Here's the output for limit = 12:

15, 21, 51, 93, 195, 381, 771, 1533, 3075, 6141

Obviously, there is another way to generate this sequence than the one I use in my script. Each term in the sequence can also be generated by multiplying 3 and 2^i - 1 if i is odd or 3 and 2^i + 1 if i is even.

3*5 = 15 where 5 = 2^2 + 1
3*7 = 21 where 7 = 2^3 - 1
3*17 = 51 where 17 = 2^4 + 1
3*31 = 93 where 31 = 2^5 - 1

and so on.