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”).

A330823
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
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, 44, 55, 67, 38, 50, 19, 31, 44, 57, 70, 83, 46, 60, 74, 88, 47, 62, 19, 34, 50, 66, 19, 35, 51, 68, 85, 102, 49, 67, 85, 103, 121, 139, 80, 99, 38, 57, 77, 97, 117, 137, 70
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
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