OFFSET
1,2
COMMENTS
Lemma: A sequence {b(n)} defined as above with m>1 cannot have values outside [1,m]. (For m=1, b=(1,0,0,0....).)
Corollary: Such a sequence {b(n)} is periodic with period <= m (except maybe for some initial terms).
Lemma 2: For any m>1, b(1) = floor( m/2 ) and if b(n)=m-1, then b(n+1)= [ m/2 ].
Proposition: As soon as there is a term b(n)=2^k, the (b-)sequence continues b(n+1)=2^(k-1),...,b(n+k)=1, b(n+k+1)=m-1 and then starts over with b(n+k+2)=b(1).
Corollary 2: Numbers m=2^k, k>2 cannot appear in the present sequence.
Proposition: For any b(0)=m>1, sooner or later the value 1 is reached.
Generate a sequence b(n) by the following rule. If b(n-1) is divisible by 2 then b(n) = b(n-1)/2. If b(n-1) is not divisible by 2 then b(n) = b(0)-(b(n-1)+1)/2. When b(n)=1 it ends. Sequence gives all m such that all numbers k with 1<=k<=m-2 appear in b(n), b(0)=m.
Sequence contains 1 and numbers m>1 such that 2m-1 is prime and -2 or 2 is a primitive root modulo 2m-1. - Max Alekseyev, May 16 2008
LINKS
Robert G. Wilson v, Table of n, a(n) for n = 1..2354.
FORMULA
This sequence as a set is the union of { 1 }, { (A105874(n)+1)/2 } and { (A001122(n)+1)/2 }. - Max Alekseyev, May 16 2008
EXAMPLE
6->3->4->2->1. 1,2,3,4=6-2 appear in b(n), b(0)=6. So 6 is a term of A137606.
MATHEMATICA
f[n_] := Block[{lst = {n}, a}, While[a = Last@ lst; a != 1, AppendTo[lst, If[ EvenQ@ a, a/2, lst[[1]] - (a + 1)/2]]]; Length@ lst - 1]; t = Array[f, 262]; Select[ Range @ 262], t[[ # ]] == # - 2 &] (* Robert G. Wilson v *)
PROG
(PARI) b137606(n)= n=[n]; for( i=1, n[1]-1, n=concat( n, if( n[i]%2, n[1]-(n[i]+1)/2, n[i]/2 )); n[i]>1 || break); n
A137606(Nmax) = for( n=1, Nmax, n==#b137606(n) && print1(n", "))
(PARI) forprime(p=3, 10^3, if(znorder(Mod(-2, p))==p-1||znorder(Mod(2, p))==p-1, print1((p+1)/2, ", ") )) \\ Max Alekseyev, May 16 2008
CROSSREFS
KEYWORD
nonn
AUTHOR
Yasutoshi Kohmoto, Apr 23 2008
EXTENSIONS
Edited & extended by M. F. Hasler, Apr 28 2008
STATUS
approved