OFFSET
1,1
COMMENTS
The necessary and sufficient condition for the constant value a(n) to be attained by the sequence b(m) is: Sum_{k=1..m-1} b(k) = b(m)*(m + 1). - Lechoslaw Ratajczak, Sep 15 2025
LINKS
Lechoslaw Ratajczak, Table of n, a(n) for n = 1..1000 (terms 1..448 from Jean-François Alcover)
MathOverflow, Mod sequences that seem to become constant
EXAMPLE
a(5) = 2, because the b sequence is 5, 1, 0, 2, 3, 5, 2, 2, 2, 2, 2, ...
PROG
(Maxima) (a(n):=(s:n, b:0, for m:2 unless s=b*(m+1) do (b:mod(s, m), s:s+b), b),
makelist(a(n), n, 1, 100)); /* Lechoslaw Ratajczak, Sep 15 2025 */
(PARI) a(n) = my(s=n, m=2, b=0); while(s!=b*(m+1), b=s % m; s += b; m++); b \\ Andrew Howroyd, Sep 15 2025
CROSSREFS
KEYWORD
sign
AUTHOR
Jean-François Alcover, Dec 31 2014
STATUS
approved
