login
A117120
a(1)=1. a(n) is smallest positive integer not occurring earlier in the sequence where a(n) is congruent to -1 (mod a(n-1)).
11
1, 2, 3, 5, 4, 7, 6, 11, 10, 9, 8, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 31, 30, 29, 28, 27, 26, 25, 24, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 95, 94, 93, 92, 91, 90, 89, 88, 87
OFFSET
1,2
COMMENTS
Sequence is a permutation of the positive integers.
The permutation is self-inverse. Except for fixed points 1, 2, 3 it consists completely of 2-cycles: (4,5), (6,7), (8,11), (9,10), (12,15), (13,14), (16,23), (17,22), ..., (24,31), ..., (32,47), ... . - Klaus Brockhaus
The permutation transforms enumeration system of positive irreducible fractions A071766/A229742 (HCS) into enumeration system A245325/A245326, and vice versa. - Yosu Yurramendi, Jun 09 2015
A092569(a(n)) = a(A092569(n)), n > 0.
A258746(a(n)) = a(A258746(n)), n > 0.
A258996(a(n)) = a(A258996(n)), n > 0.
A054429(a(n)) = a(A054429(n)), n > 0.
a(n) = A054429(A063946(n)) = A063946(A054429(n)), n > 0. - Yosu Yurramendi, Mar 23 2017
FORMULA
For n >= 2: If a(n-1) = 2^m, m=positive integer, then a(n)= 2^(m+1)-1. If a(n-1) = 3*2^m, m= nonnegative integer, then a(n) = 3*2^(m+1)-1. Otherwise, a(n) = a(n-1) -1.
For n >= 2: a(2*n) = 2*a(n)+1, a(2*n+1) = 2*a(n). - Yosu Yurramendi, Jun 08 2015
MAPLE
A[1]:= 1: A[2]:= 2: B[1]:= 0: B[2]:= 0:
for n from 3 to 100 do
for m from A[n-1]-1 by A[n-1] while assigned(B[m]) do od:
A[n]:= m;
B[m]:= 0;
od:
seq(A[n], n=1..100); # Robert Israel, Jun 09 2015
MATHEMATICA
f[n_] := Block[{a = {1}, i, k}, Do[k = 1; While[Or[Mod[k, a[[i - 1]]] != a[[i - 1]] - 1, MemberQ[a, k]], k++]; AppendTo[a, k], {i, 2, n}]; a]; f@ 120 (* Michael De Vlieger, Jun 11 2015 *)
A[n_]:= If[n<4, n, If[EvenQ[n], 2A[n/2] + 1, 2A[(n - 1)/2]]]; Table[A[n], {n, 100}] (* Indranil Ghosh, Mar 21 2017 *)
f[lst_List] := Block[{k = 2, m = lst[[-1]]}, While[ MemberQ[lst, k] || 1 + Mod[k, m] != m, k++]; Append[lst, k]]; Nest[f, {1}, 70] (* Robert G. Wilson v, Jan 22 2018 *)
PROG
(R)
a <- 1:3 # If it were c(1, 3, 2), it would be A054429
maxn <- 50 # by choice
#
for(n in 2:maxn){
a[2*n ] <- 2*a[n]+1
a[2*n+1] <- 2*a[n]
}
#
a
# Yosu Yurramendi, Jun 08 2015
(PARI) A(n) = if(n<4, n, if(n%2, 2*A(n\2), 2*A(n/2)+1));
for(n=1, 50, print1(A(n), ", ")) \\ Indranil Ghosh, Mar 21 2017
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Leroy Quet, Apr 19 2006
EXTENSIONS
More terms from Klaus Brockhaus
STATUS
approved