login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A327420 Building sums recursively with the divisibility properties of their partial sums. 5
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 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

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.

LINKS

Peter Luschny, Table of n, a(n) for n = 0..10000

Index entries for sequences that are permutations of the nonnegative integers

FORMULA

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

EXAMPLE

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]

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);

PROG

(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)])

(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

CROSSREFS

Cf. A327093, A327487, A057032, A069829.

Sequence in context: A035493 A070038 A328638 * A119790 A272214 A319785

Adjacent sequences:  A327417 A327418 A327419 * A327421 A327422 A327423

KEYWORD

nonn

AUTHOR

Peter Luschny, Sep 14 2019

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified January 27 22:46 EST 2022. Contains 350654 sequences. (Running on oeis4.)