OFFSET
1,3
COMMENTS
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.
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.
LINKS
Scott R. Shannon, Graph showing a(n) for n = 1 to 2000000. The blue line is the x axis.
Wikipedia, Prime Number Theorem and Prime Counting Function.
MATHEMATICA
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 *)
CROSSREFS
KEYWORD
sign,look
AUTHOR
Scott R. Shannon, Jan 02 2020
STATUS
approved