%I #33 Sep 05 2019 04:37:54
%S 4,8,16,17,11,10,17,16,17,16,16,17,10,11,5,4,11,10,16,17,11,10,17,16,
%T 16,17,16,21,25,26,27,28,28,29,23,22,29,28,29,28,28,29,22,23,17,16,22,
%U 23,16,17,11,9,10,12,17,15,21,23,16,18,26,28,36,38,47,45
%N The sequence is always extended by subtracting the n-th digit of the sequence from a(n) if a(n) is prime, else adding it to a(n), starting with a(1) = 4.
%C Up to 10^6 the terms increase approximately linearly, and no cycles are visible. As we approach a million terms the terms are 3590238, 3590240, 3590242, 3590248, 3590251, 3590251, 3590257, 3590259, 3590261, 3590267, 3590270, 3590279, 3590285, 3590287, 3590289, 3590295, 3590298, 3590306, 3590312, 3590314, 3590316, 3590322, 3590326, 3590326, 3590332, 3590334, 3590336, 3590342, 3590346, ..., and the smallest values not yet encountered at that point are 2, 3, 6, 7, 13, 14, 19, 20, 24, 30, 31, 32, 33, 34, 35, 37, 39, 40, 41, 42, 43, 44, 46, 49, 51, 53, 55, 56, 57, 58, 59, 60, 61, 66, 67, 68, 69, 70, 75, 76, 77, 78, 79, 80, 81, 83, 85, 86, 87, 88, 89, 90, 91, 92, 100, 108, 109, 110, 113, 114, 115, 116, 117, 118, ... - _Lars Blomberg_, Aug 06 2019
%H Lars Blomberg, <a href="/A309521/b309521.txt">Table of n, a(n) for n = 1..10000</a>
%e The sequence starts with 4,8,16,17,11,10,17,16,...
%e As a(1) = 4 (not a prime), we have a(2) = a(1) + [the 1st digit of the seq] = 4 + 4 = 8;
%e as a(2) = 8 (not a prime), we have a(3) = a(2) + [the 2nd digit of the seq] = 8 + 8 = 16;
%e as a(3) = 16 (not a prime), we have a(4) = a(3) + [the 3rd digit of the seq] = 16 + 1 = 17;
%e as a(4) = 17 (a prime), we have a(5) = a(4) - [the 4th digit of the seq] = 17 - 6 = 11;
%e as a(5) = 11 (a prime), we have a(6) = a(5) - [the 5th digit of the seq] = 11 - 1 = 10;
%e etc.
%o (PARI) v=4; d=[]; for (n=1, 66, print1 (v ", "); d=concat(d, digits(v)); v+=d[n]*if (isprime(v), -1, +1)) \\ _Rémy Sigrist_, Aug 06 2019
%Y Cf. A309529 (same idea, but dealing with even numbers instead of primes).
%K base,nonn
%O 1,1
%A _Eric Angelini_ and _Lars Blomberg_, Aug 06 2019
%E More terms from _Rémy Sigrist_, Aug 06 2019
|