A069829
a(n) = PS(n)(2n), where PS is described in A057032.
Original entry on oeis.org
2, 5, 9, 11, 13, 19, 17, 23, 31, 26, 25, 40, 29, 47, 58, 51, 37, 69, 41, 56, 71, 67, 49, 82, 70, 73, 92, 95, 61, 123, 65, 105, 118, 94, 112, 148, 77, 107, 134, 116, 85, 143, 89, 122, 177, 127, 97, 166, 130, 133, 175, 162, 109, 211, 159, 188, 190, 154, 121, 248, 125
Offset: 1
-
A069829 := proc(n) local N, k; N := n;
for k from n by -1 to 1 do
if irem(N, k) = 0 then
if irem(N, k)::odd then
N := N - k;
else
N := N + k;
fi;
fi;
od;
N end:
seq(A069829(n), n = 1..61); # Peter Luschny, Sep 14 2019
A007062
Let P(n) of a sequence s(1),s(2),s(3),... be obtained by leaving s(1),...,s(n) fixed and reversing every n consecutive terms thereafter; apply P(2) to 1,2,3,... to get PS(2), then apply P(3) to PS(2) to get PS(3), then apply P(4) to PS(3), etc. This sequence is the limit of PS(n).
Original entry on oeis.org
1, 2, 4, 5, 7, 12, 14, 15, 23, 28, 30, 41, 43, 48, 56, 67, 69, 84, 86, 87, 111, 116, 124, 139, 141, 162, 180, 181, 183, 224, 232, 237, 271, 276, 278, 315, 333, 338, 372, 383, 385, 426, 428, 439, 473, 478, 538, 543, 551, 556, 620
Offset: 1
PS(2) begins with 1,2,4,3,6,5,8; PS(3) with 1,2,4,5,6,3,10; PS(4) with 1,2,4,5,7,10,3.
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Cf.
A057030 (here we have "s(1), ..., s(n)", whereas 057030 has "s(1), ..., s(n-1)").
-
(* works per the name description *)
a007062=Range[x=3500]; Do[a007062=Flatten[Join[{Take[a007062,n]},Map[Reverse,Partition[Drop[a007062,n],n]]]],{n,2,NestWhile[#+1&,1,(x=# Floor[x/#])>0&]-1}]; a007062
(* works by making McGarvey's array *) a=Range[x=10000];rows=Table[a=Flatten[Map[Reverse,Partition[a,n]]],{n,NestWhile[#+1&,1,(x=# Floor[x/#])>0&]-1}];a007062=Map[First,rows] (* Peter J. C. Moses, Nov 10 2016 *)
A057030
Let P(n) of a sequence s(1),s(2),s(3),... be obtained by leaving s(1),...,s(n-1) fixed and reversing every n consecutive terms thereafter; apply P(2) to 1,2,3,... to get PS(2), then apply P(3) to PS(2) to get PS(3), then apply P(4) to PS(3), etc. The limit of PS(n) is A057030.
Original entry on oeis.org
1, 3, 4, 6, 11, 13, 14, 22, 27, 29, 40, 42, 47, 55, 66, 68, 83, 85, 86, 110, 115, 123, 138, 140, 161, 179, 180, 182, 223, 231, 236, 270, 275, 277, 314, 332, 337, 371, 382, 384, 425, 427, 438, 472, 477, 537, 542, 550, 555, 619, 630
Offset: 1
PS(2) begins with 1,3,2,5,4,7,6;
PS(3) begins with 1,3,4,5,2,9,6;
PS(4) begins with 1,3,4,6,9,2,5.
-
a057030=Range[x=3500]; Do[a057030=Flatten[Join[{Take[a057030,n-1]},Map[Reverse,Partition[Drop[a057030,n-1],n]]]],{n,2,NestWhile[#+1&,1,(x=# Floor[x/#])>0&]-1}]; a057030 (* Peter J. C. Moses, Nov 10 2016 *)
A057033
Let P(n) of a sequence s(1),s(2),s(3),... be obtained by leaving s(1),...s(n-1) fixed and reverse-cyclically permuting every n consecutive terms thereafter; apply P(2) to 1,2,3,... to get PS(2), then apply P(3) to PS(2) to get PS(3), then apply P(4) to PS(3), etc. The limit of PS(n) is A057033.
Original entry on oeis.org
1, 3, 5, 2, 9, 11, 6, 15, 17, 10, 21, 12, 4, 27, 29, 18, 19, 35, 22, 39, 41, 8, 45, 28, 30, 51, 36, 34, 57, 59, 14, 43, 65, 42, 69, 71, 24, 53, 77, 7, 81, 60, 54, 87, 64, 58, 67, 95, 26, 99, 101, 37, 105, 107, 70, 111, 84, 32, 88, 93, 78, 47
Offset: 1
PS(2) begins with 1,3,2,5,4,7,6; PS(3) with 1,3,5,4,2,6,9; PS(4) with 1,3,5,2,6,9,4.
-
terms = 62; maxTerms = terms^2; Clear[PS]; PS[n_] := PS[n] = If[n == 1, Range[maxTerms], Join[PS[n-1][[1 ;; n-1]], RotateLeft /@ Partition[ PS[n-1][[n ;; All]], n]] // Flatten]; PS[1]; PS[n = 2]; While[PS[n][[1 ;; terms]] != PS[n-1][[1 ;; terms]], n++]; A057033 = PS[n][[1 ;; terms]] (* Jean-François Alcover, Apr 24 2017 *)
A327093
Sequence obtained by swapping each (k*(2n))-th element of the positive integers with the (k*(2n-1))-th element, for all k > 0, in ascending order.
Original entry on oeis.org
2, 3, 7, 5, 11, 13, 15, 10, 17, 19, 23, 25, 27, 21, 40, 16, 35, 36, 39, 37, 58, 33, 47, 50, 52, 43, 45, 34, 59, 78, 63, 31, 76, 55, 82, 67, 75, 57, 99, 56, 83, 112, 87, 61, 126, 69, 95, 92, 97, 96, 133, 71, 107, 81, 142, 79, 139, 91, 119, 155, 123, 93, 122, 51, 151, 146, 135
Offset: 1
-
func a(n int) int {
for k := n; k > 0; k-- {
if n%k == 0 {
if (n/k)%2 == 0 {
n = n - k
} else {
n = n + k
}
}
}
return n
}
-
def a(n):
for k in srange(n, 0, -1):
if k.divides(n):
n += k if is_odd(n//k) else -k
return n
print([a(n) for n in (1..67)]) # Peter Luschny, Sep 14 2019
A057063
Let P(n) of a sequence s(1),s(2),s(3),... be obtained by leaving s(1),...,s(n) fixed and reverse-cyclically permuting every n consecutive terms thereafter; apply P(2) to 1,2,3,... to get PS(2), then apply P(3) to PS(2) to get PS(3), then apply P(4) to PS(3), etc. The limit of PS(n) is A057063.
Original entry on oeis.org
1, 2, 4, 6, 3, 10, 12, 7, 16, 18, 11, 22, 13, 5, 28, 30, 19, 20, 36, 23, 40, 42, 9, 46, 29, 31, 52, 37, 35, 58, 60, 15, 44, 66, 43, 70, 72, 25, 54, 78, 8, 82, 61, 55, 88, 65, 59, 68, 96, 27, 100, 102, 38, 106, 108, 71, 112, 85, 33, 89, 94, 79, 48, 126, 83, 130
Offset: 1
PS(2) begins with 1,2,4,3,6,5,8;
PS(3) begins with 1,2,4,6,5,3,7;
PS(4) begins with 1,2,4,6,3,7,10.
-
get(v, iv) = if (iv > #v, 0, v[iv]);
rcp(nbn, nbp, startv, v) = {w = vector(nbn); for (k=1, nbn, if (k % nbp, jv = startv+k, jv = startv+k-nbp); w[k] = get(v, jv);); w;}
lista(nn) = {v = vector(nn, n, n); print1(v[1], ", ", v[2], ", "); startv = 3; for (n=3, nn, w = rcp(nn-n+1, n-1, startv, v); startv = 2; if (w[1] == 0, break); print1(w[1], ", "); v = w;);} \\ Michel Marcus, Feb 19 2016
A057064
Let P(n) of a sequence s(1),s(2),s(3),... be obtained by leaving s(1),...,s(n) fixed and forward-cyclically permuting every n consecutive terms thereafter; apply P(2) to 1,2,3,... to get PS(2), then apply P(3) to PS(2) to get PS(3), then apply P(4) to PS(3), etc. The limit of PS(n) is A057064.
Original entry on oeis.org
1, 2, 4, 5, 8, 7, 11, 9, 17, 16, 22, 13, 23, 15, 28, 29, 37, 19, 34, 21, 44, 36, 40, 25, 54, 35, 46, 47, 51, 31, 67, 33, 79, 53, 58, 56, 82, 39, 64, 60, 89, 43, 87, 45, 97, 88, 76, 49, 120, 65, 112, 77, 102, 55, 104, 80, 145, 84, 94, 61, 142, 63, 100, 114, 174
Offset: 1
PS(2) begins with 1,2,4,3,6,5,8; PS(3) with 1,2,4,5,3,6,10; PS(4) with 1,2,4,5,8,3,6.
-
get(v, iv) = if (iv > #v, 0, v[iv]);
fcp(nbn, nbp, startv, v) = {w = vector(nbn); for (k=1, nbn, j = k % nbp; if (j == 1, jv = startv+k+nbp-2, jv = startv+k-2); w[k] = get(v, jv);); w;}
lista(nn) = {v = vector(nn, n, n); print1(v[1], ", ", v[2], ", "); startv = 3; for (n=3, nn, w = fcp(nn-n+1, n-1, startv, v); startv = 2; if (w[1] == 0, break); print1(w[1], ", "); v = w;);} \\ Michel Marcus, Feb 19 2016
A327420
Building sums recursively with the divisibility properties of their partial sums.
Original entry on oeis.org
1, 0, 2, 3, 6, 5, 9, 7, 15, 4, 14, 11, 21, 13, 16, 8, 35, 17, 26, 19, 30, 12, 28, 23, 46, 18, 38, 10, 49, 29, 45, 31, 77, 20, 50, 27, 63, 37, 52, 24, 68, 41, 54, 43, 74, 25, 64, 47, 96, 34, 62, 32, 95, 53, 70, 42, 94, 36, 86, 59, 91, 61, 88, 33, 166, 51, 85
Offset: 0
The computation of a(9) = 4:
[ k: s(k) = s(k+1) + divsign(s(k+1),k)]
[10: 0, 10, -10]
[ 9: 9, 0, 9]
[ 8: 9, 9, 0]
[ 7: 9, 9, 0]
[ 6: 9, 9, 0]
[ 5: 9, 9, 0]
[ 4: 9, 9, 0]
[ 3: 6, 9, -3]
[ 2: 4, 6, -2]
-
divsign(s, k) = rem(s, k) == 0 ? (-1)^div(s, k)*k : 0
function A327420(n)
s = n + 1
for k in n+1:-1:2 s += divsign(s, k) end
s
end
[A327420(n) for n in 0:66] |> println
-
divsign := (s, k) -> `if`(irem(s, k) <> 0, 0, (-1)^iquo(s,k)*k):
A327420 := proc(n) local s, k; s := n + 1;
for k from s by -1 to 2 do
s := s + divsign(s, k) od;
return s end:
seq(A327420(n), n=0..66);
-
def A327420(n):
s = n + 1
r = srange(s, 1, -1)
for k in r:
if k.divides(s):
s += (-1)^(s//k)*k
return s
print([A327420(n) for n in (0..66)])
A327487
T(n, k) are the summands given by the generating function of A327420(n), triangle read by rows, T(n,k) for 0 <= k <= n.
Original entry on oeis.org
1, 2, -2, 3, -3, 2, 4, -4, 3, 0, 5, -5, 4, 0, 2, 6, -6, 5, 0, 0, 0, 7, -7, 6, 0, 0, 3, 0, 8, -8, 7, 0, 0, 0, 0, 0, 9, -9, 8, 0, 0, 0, 4, 3, 0, 10, -10, 9, 0, 0, 0, 0, 0, -3, -2, 11, -11, 10, 0, 0, 0, 0, 5, 0, -3, 2, 12, -12, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 0
Triangle starts (at the end of the line is the row sum (A327420)):
[ 0] [ 1] 1
[ 1] [ 2, -2] 0
[ 2] [ 3, -3, 2] 2
[ 3] [ 4, -4, 3, 0] 3
[ 4] [ 5, -5, 4, 0, 2] 6
[ 5] [ 6, -6, 5, 0, 0, 0] 5
[ 6] [ 7, -7, 6, 0, 0, 3, 0] 9
[ 7] [ 8, -8, 7, 0, 0, 0, 0, 0] 7
[ 8] [ 9, -9, 8, 0, 0, 0, 4, 3, 0] 15
[ 9] [10, -10, 9, 0, 0, 0, 0, 0, -3, -2] 4
[10] [11, -11, 10, 0, 0, 0, 0, 5, 0, -3, 2] 14
-
def divsign(s, k):
if not k.divides(s): return 0
return (-1)^(s//k)*k
def A327487row(n):
s = n + 1
r = srange(s, 1, -1)
S = [-divsign(s, s)]
for k in r:
s += divsign(s, k)
S.append(-divsign(s, k))
return S
# Prints the triangle like in the example section.
for n in (0..10):
print([n], A327487row(n), sum(A327487row(n)))
Showing 1-9 of 9 results.
Comments