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

%I #36 Nov 20 2019 05:07:56

%S 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,

%T 38,10,49,29,45,31,77,20,50,27,63,37,52,24,68,41,54,43,74,25,64,47,96,

%U 34,62,32,95,53,70,42,94,36,86,59,91,61,88,33,166,51,85

%N Building sums recursively with the divisibility properties of their partial sums.

%C 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.

%C 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.

%C Apparently the sequence is a permutation of the nonnegative integers.

%H Peter Luschny, <a href="/A327420/b327420.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the nonnegative integers</a>

%F For p prime, a(p) = p. - _Bernard Schott_, Sep 14 2019

%e The computation of a(9) = 4:

%e [ k: s(k) = s(k+1) + divsign(s(k+1),k)]

%e [10: 0, 10, -10]

%e [ 9: 9, 0, 9]

%e [ 8: 9, 9, 0]

%e [ 7: 9, 9, 0]

%e [ 6: 9, 9, 0]

%e [ 5: 9, 9, 0]

%e [ 4: 9, 9, 0]

%e [ 3: 6, 9, -3]

%e [ 2: 4, 6, -2]

%p divsign := (s, k) -> `if`(irem(s, k) <> 0, 0, (-1)^iquo(s,k)*k):

%p A327420 := proc(n) local s, k; s := n + 1;

%p for k from s by -1 to 2 do

%p s := s + divsign(s, k) od;

%p return s end:

%p seq(A327420(n), n=0..66);

%o (SageMath)

%o def A327420(n):

%o s = n + 1

%o r = srange(s, 1, -1)

%o for k in r:

%o if k.divides(s):

%o s += (-1)^(s//k)*k

%o return s

%o print([A327420(n) for n in (0..66)])

%o (Julia)

%o divsign(s, k) = rem(s, k) == 0 ? (-1)^div(s, k)*k : 0

%o function A327420(n)

%o s = n + 1

%o for k in n+1:-1:2 s += divsign(s, k) end

%o s

%o end

%o [A327420(n) for n in 0:66] |> println

%Y Cf. A327093, A327487, A057032, A069829.

%K nonn

%O 0,3

%A _Peter Luschny_, Sep 14 2019

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 30 06:02 EDT 2024. Contains 374737 sequences. (Running on oeis4.)