login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(1) = 1; for n > 1, a(n) = a(n-1) - n if n is prime, otherwise a(n) = a(n-1) + floor(n/(log(n)-1)).
1

%I #19 Jan 05 2020 11:38:48

%S 1,-1,-4,6,1,8,1,8,15,22,11,19,6,14,22,31,14,23,4,14,24,34,11,22,33,

%T 44,55,67,38,50,19,31,44,57,70,83,46,60,74,88,47,62,19,34,50,66,19,35,

%U 51,68,85,102,49,67,85,103,121,139,80,99,38,57,77,97,117,137,70

%N a(1) = 1; for n > 1, a(n) = a(n-1) - n if n is prime, otherwise a(n) = a(n-1) + floor(n/(log(n)-1)).

%C The Prime Number Theorem shows that the probability of a random number not greater than x being prime is approximately 1/log(x), therefore the probability of a number being composite in the same range is approximately (log(x)-1)/log(x). As this sequence subtracts n from the previous term if n is prime, or adds n with a weighting of 1/(log(n)-1) if n is composite, its expected value as n goes to infinity is approximately n*(1/(log(n)-1))*((log(n)-1)/log(n)) - n*(1/log(n)) = 0. We therefore expect that a(n)/n approaches 0 as n goes to infinity.

%C In the first 2 million terms the sequence changes sign 1900 times, has a maximum positive value of 160213275 at a(1772200), and a maximum negative value of -29535301 at a(1513751). The majority of terms are positive. See the image link below.

%H Scott R. Shannon, <a href="/A330823/a330823.png">Graph showing a(n) for n = 1 to 2000000</a>. The blue line is the x axis.

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Prime_number_theorem">Prime Number Theorem</a> and <a href="https://en.wikipedia.org/wiki/Prime-counting_function">Prime Counting Function</a>.

%t a[1] = 1; a[n_] := a[n] = a[n - 1] + If[PrimeQ[n], -n, Floor[n/(Log[n] - 1)]]; Array[a, 67] (* _Amiram Eldar_, Jan 05 2020 *)

%Y Cf. A000040, A057835, A060769, A060770, A050499, A085581.

%K sign,look

%O 1,3

%A _Scott R. Shannon_, Jan 02 2020