cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-5 of 5 results.

A057032 Let P(n) of a sequence s(1), s(2), s(3), ... be obtained by leaving s(1), ..., s(n-1) 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) as n -> oo is this sequence.

Original entry on oeis.org

1, 3, 4, 7, 6, 10, 8, 16, 15, 21, 12, 22, 14, 27, 28, 36, 18, 33, 20, 43, 35, 39, 24, 53, 34, 45, 46, 50, 30, 66, 32, 78, 52, 57, 55, 81, 38, 63, 59, 88, 42, 86, 44, 96, 87, 75, 48, 119, 64, 111, 76, 101, 54, 103, 79, 144, 83, 93, 60, 141, 62, 99, 113, 173, 91, 136, 68, 139
Offset: 1

Views

Author

Clark Kimberling, Jul 29 2000

Keywords

Comments

Conjecture: a(n) - 1 is prime if and only if a(n) = n + 1. - Mikhail Kurkov, Mar 10 2022

Examples

			PS(2) begins with 1, 3, 2, 5, 4, 7, 6;
PS(3) begins with 1, 3, 4, 2, 5, 9, 7;
PS(4) begins with 1, 3, 4, 7, 2, 5, 9.
		

Crossrefs

Programs

  • MATLAB
    function m = A057032(i) m = PS(i, i); function m = PS(i, n) if i == 1 m = n; elseif n < i m = PS(i - 1, n); else if mod(n, i) == 0 m = PS(i - 1, n + i - 1); else m = PS(i - 1, n - 1); end end
    
  • Mathematica
    PS[i_, n_] := If[i == 1, n, If[n < i, PS[i-1, n], If[Mod[n, i] == 0, PS[i-1, n+i-1], PS[i-1, n-1]]]]; a[n_] := PS[n, n]; Table[a[n], {n, 1, 68}] (* Jean-François Alcover, Oct 20 2011, after MATLAB *)
  • PARI
    a(n) = { my (p=0); forstep (d=n, 1, -1, if (p%d==0, p+=d)); p } \\ Rémy Sigrist, Aug 25 2020

Formula

Conjecture: a(n) = A057064(n+1) - 1 for n > 0. - Mikhail Kurkov, Mar 10 2022

Extensions

More terms from David Wasserman, Apr 22 2002

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

Views

Author

Jennifer Buckley, Sep 13 2019

Keywords

Comments

Start with the sequence of positive integers [1, 2, 3, 4, 5, 6, 7, 8, ...].
Swap all pairs specified by k=1, that is, do the swaps (2,1),(4,3),(6,5),(8,7),..., resulting in [2, 1, 4, 3, 6, 5, 8, 7, ...], so the first term of the final sequence is 2 (No swaps for k>1 will affect this term).
Swap all pairs specified by k=2, that is, do the swaps (4,2),(8,6),(12,10),(16,14),..., resulting in [2, 3, 4, 1, 6, 7, 8, 5, ...], so the second term of the final sequence is 3 (No swaps for k>2 will affect this term).
Swap all pairs specified by k=3, that is, do the swaps (6,3),(12,9),(18,15),(24,21),... .
Continue for all values of k.
The complementary sequence 1, 4, 6, 8, 9, 12, 14, 18, 20, 22, 24, 26, 28, ... lists the numbers that never appear. Is there an alternative characterization of these numbers?
Equivalently, is there a characterization of the numbers (2, 3, 5, 7, 10, 11, 13, 15, 16, 17, 19, 21, 23, ...) that do appear? - N. J. A. Sloane, Sep 13 2019

Crossrefs

For the sorted terms and the missing terms see A327445, A327446.

Programs

  • Go
    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
    }
    
  • SageMath
    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

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

Views

Author

Clark Kimberling, Aug 01 2000

Keywords

Comments

It appears that this is not a permutation of the integers: 3, 6, 10, 12, 14, 18, 20, 24, ... are not terms. - Michel Marcus, Feb 19 2016
Indeed, see the first formula here and the first comment in A069829. - Mikhail Kurkov, Mar 08 2023

Examples

			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.
		

Crossrefs

Programs

  • PARI
    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

Formula

a(n) = A057032(n-1) + 1 for n > 1. - Sean A. Irvine, May 19 2022

Extensions

More terms from 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

Views

Author

Peter Luschny, Sep 14 2019

Keywords

Comments

Let R(n) = [k : n + 1 >= k >= 2] and divsign(s, k) = 0 if k does not divide s, else k if s/k is even and else -k. Compute s(k) = s(k+1) + divsign(s(k+1), k) with initial value s(n+2) = n + 1, k running down from n + 1 to 2. Then a(n) = s(2) if n > 0 and a(0) = s(n+2) = 0 + 1 = 1 as R(0) is empty in this case.
Examples: If n = 8 then R(8) = [9, 8, ..., 2] and the partial sums s are [0, 8, 8, 8, 8, 12, 15, 15] giving a(8) = 15. If p is prime, then the partial sums are [0, p, p, ..., p] since p is the only integer in R(p) diving p, i. e. the primes are the fixed points of this sequence. In the example section the computation of a(9) is traced.
Apparently the sequence is a permutation of the nonnegative integers.

Examples

			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]
		

Crossrefs

Programs

  • Julia
    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
  • Maple
    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);
  • SageMath
    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)])
    

Formula

For p prime, a(p) = p. - Bernard Schott, Sep 14 2019

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

Views

Author

Peter Luschny, Sep 14 2019

Keywords

Examples

			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
		

Crossrefs

Programs

  • SageMath
    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)))

Formula

Sum_{k=0..n} T(n, k) = A327420(n).
Showing 1-5 of 5 results.