Let $n\geq 1$ be an integer. In this post we denote the sum of remainders function as $$S(n)=\sum_{k=1}^n n \bmod k,$$ for example $S(1)=S(2)=0+0$ and $S(5)=0+1+2+1+0=4$. In the literature there are problems that were studied related to the condition $\gcd(n,f(n))=1$, for a given arithmetic function $f(n)$.

Question.A) Is it possible to provide roughly a cheap bound for the cardinality $$\#\{1\leq n\leq x|\gcd(n,S(n))=1\}$$ as $x$ grows to $\infty$?

B) The sequence of primes $p$ that satisfy the condition $$\gcd(p,S(p))>1$$ starts as $2,11,17,2161,\ldots$. Can you provide us any idea about if this sequence has finitely many terms?

Just to emphasize, since I'm asking two questions, only is required that you provide a cheap bound for A) and a suitable reasoning/heuristic for B), to get idea for these problems.

**Computational evidence and documentation for Question B.** We've the following script in Pari/GP showing the first few terms

`for(n=1, 10000, if(gcd(n,sum(k=1,n,n%k))>1&&isprime(n)==1,print(n)))`

that you can evaluate on the website *Sage Cell Server* choosing as Language *GP*. Here the string `sum(k=1,n,n%k)`

is our sum of remainders $S(n)$ with `n%k`

coding $n \bmod k$ for each integer $1\leq k\leq n$.