OFFSET
1,2
COMMENTS
Or, a(1) = 1, a(n) = n + a(n-1) if n does not divide a(n-1) else a(n) = a(n-1). E.g. a(6) = a(5) = 12 as 6 divides 12. a(10) = 10+a(9) = 10+27 = 37.
LINKS
B. D. Swan, Table of n, a(n) for n = 1..90000
Index entries for linear recurrences with constant coefficients, signature (1,0,2,-2,0,-1,1).
FORMULA
From Colin Barker, Feb 18 2020: (Start)
G.f.: x*(1 + 2*x + 2*x^3 + x^4) / ((1 - x)^3*(1 + x + x^2)^2).
a(n) = a(n-1) + 2*a(n-3) - 2*a(n-4) - a(n-6) + a(n-7) for n>7.
(End)
Sum_{n>=1} 1/a(n) = Pi/sqrt(3)*tanh(Pi/(2*sqrt(3))) + Pi^2/9. - Amiram Eldar, Sep 21 2023
MATHEMATICA
LinearRecurrence[{1, 0, 2, -2, 0, -1, 1}, {1, 3, 3, 7, 12, 12, 19}, 60] (* Harvey P. Dale, Jun 29 2022 *)
PROG
(Perl)
my @a = (1); for (my $n = 1; $n <= 90000; $n ++) {
$a[$n] = $a[$n - 1] + ($a[$n - 1] % $n != 0 ? $n : 0);
print "$n $a[$n]\n";
} # Georg Fischer Feb 18 2020
(Magma) [(n mod 3 eq 1) select (n+2)^2/3 - n-1 else (n+((n mod 3)^2) mod 3 )^2/3 : n in [1..50]]; // Marius A. Burtea, Feb 19 2020
(PARI) Vec(x*(1 + 2*x + 2*x^3 + x^4) / ((1 - x)^3*(1 + x + x^2)^2) + O(x^50)) \\ Colin Barker, Feb 19 2020
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Amarnath Murthy, Feb 26 2002
EXTENSIONS
Entry revised by N. J. A. Sloane, Mar 13 2006
STATUS
approved