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.

A327420 Building sums recursively with the divisibility properties of their partial sums.

This page as a plain text file.
%I A327420 #36 Nov 20 2019 05:07:56
%S A327420 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 A327420 38,10,49,29,45,31,77,20,50,27,63,37,52,24,68,41,54,43,74,25,64,47,96,
%U A327420 34,62,32,95,53,70,42,94,36,86,59,91,61,88,33,166,51,85
%N A327420 Building sums recursively with the divisibility properties of their partial sums.
%C A327420 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 A327420 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 A327420 Apparently the sequence is a permutation of the nonnegative integers.
%H A327420 Peter Luschny, <a href="/A327420/b327420.txt">Table of n, a(n) for n = 0..10000</a>
%H A327420 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the nonnegative integers</a>
%F A327420 For p prime, a(p) = p. - _Bernard Schott_, Sep 14 2019
%e A327420 The computation of a(9) = 4:
%e A327420 [ k: s(k) = s(k+1) + divsign(s(k+1),k)]
%e A327420 [10:   0,    10,       -10]
%e A327420 [ 9:   9,     0,         9]
%e A327420 [ 8:   9,     9,         0]
%e A327420 [ 7:   9,     9,         0]
%e A327420 [ 6:   9,     9,         0]
%e A327420 [ 5:   9,     9,         0]
%e A327420 [ 4:   9,     9,         0]
%e A327420 [ 3:   6,     9,        -3]
%e A327420 [ 2:   4,     6,        -2]
%p A327420 divsign := (s, k) -> `if`(irem(s, k) <> 0, 0, (-1)^iquo(s,k)*k):
%p A327420 A327420 := proc(n) local s, k; s := n + 1;
%p A327420     for k from s by -1 to 2 do
%p A327420         s := s + divsign(s, k) od;
%p A327420 return s end:
%p A327420 seq(A327420(n), n=0..66);
%o A327420 (SageMath)
%o A327420 def A327420(n):
%o A327420     s = n + 1
%o A327420     r = srange(s, 1, -1)
%o A327420     for k in r:
%o A327420         if k.divides(s):
%o A327420             s += (-1)^(s//k)*k
%o A327420     return s
%o A327420 print([A327420(n) for n in (0..66)])
%o A327420 (Julia)
%o A327420 divsign(s, k) = rem(s, k) == 0 ? (-1)^div(s, k)*k : 0
%o A327420 function A327420(n)
%o A327420     s = n + 1
%o A327420     for k in n+1:-1:2 s += divsign(s, k) end
%o A327420     s
%o A327420 end
%o A327420 [A327420(n) for n in 0:66] |> println
%Y A327420 Cf. A327093, A327487, A057032, A069829.
%K A327420 nonn
%O A327420 0,3
%A A327420 _Peter Luschny_, Sep 14 2019