OFFSET
1,2
COMMENTS
In spite of the definition, this is simply 1, 3, then numbers of the form n*(n+7)/2 (A055999). In other words, a(n) = (n-3)*(n+4)/2 for n >= 3. The proof is by induction: For n > 3, a(n-1) = (n-4)*(n+3)/2 is composite, so a(n) = a(n-1) + n = (n-3)*(n+4)/2. - Dean Hickerson, T. D. Noe, Paul C. Leopardi, Labos Elemer and others, Oct 04 2004
If a 2-set Y and a 3-set Z, having one element in common, are subsets of an n-set X then a(n) is the number of 3-subsets of X intersecting both Y and Z. - Milan Janjic, Oct 03 2007
LINKS
Milan Janjic, Two Enumerative Functions.
FORMULA
a(1) = 1, a(2) = 3; a(n+1) = a(n)+n if a(n) is not a prime; a(n+1) = a(n)-n if a(n) is prime.
EXAMPLE
a(1) = 1
a(2) = a(1) + 2 = 3, which is prime, so
a(3) = a(2) - 3 = 0, which is not prime, so
a(4) = a(3) + 4 = 4, which is not prime, etc.
MATHEMATICA
{ta={1, 3}, tb={{0}}}; Do[s=Last[ta]; If[PrimeQ[s], ta=Append[ta, s-n]]; If[ !PrimeQ[s], ta=Append[ta, s+n]]; Print[{a=Last[ta], b=(n-3)*(n+4)/2, a-b}]; tb=Append[tb, a-b], {n, 3, 100000}]; {ta, {tb, Union[tb]}} (* Labos Elemer, Oct 07 2004 *)
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Amarnath Murthy, Aug 30 2002
EXTENSIONS
More terms from Jason Earls, Sep 01 2002
More terms from Labos Elemer, Oct 07 2004
STATUS
approved