login
A175778
Length of the longest positive arithmetic progression, with nonzero common difference, that sums to n.
1
1, 1, 2, 2, 2, 3, 2, 2, 3, 4, 2, 3, 2, 4, 5, 4, 2, 4, 2, 5, 6, 4, 2, 4, 5, 4, 6, 7, 2, 5, 2, 4, 6, 4, 7, 8, 2, 4, 6, 5, 2, 7, 2, 8, 9, 4, 2, 6, 7, 5, 6, 8, 2, 9, 10, 7, 6, 4, 2, 8, 2, 4, 9, 8, 10, 11, 2, 8, 6, 7, 2, 9, 2, 4, 10, 8, 11, 12, 2, 8, 9, 4, 2, 8, 10, 4, 6, 11, 2, 12, 13, 8, 6, 4, 10, 8, 2, 7, 11
OFFSET
1,3
COMMENTS
If n is an odd prime then a(n)=2.
It appears that if n is at least 10 and twice a prime, then a(n)=4.
If n is the triangular number k*(k+1)/2 (A000217), then a(n)=k.
As a follow-up to previous comment, it appears that, if sequence is displayed as a regular triangle, then the diagonals starting at rows 1, 2, 4, 7, 11, 16, 22, ...(likely A000124) are constituted of consecutive integers. - Michel Marcus, Jul 13 2014
LINKS
EXAMPLE
The arithmetic progressions {1,3,5} and {2,3,4}, of length 3, sum to 9. No longer arithmetic progression sums to 9, so a(9)=3.
As a triangle, sequence starts:
1;
1, 2;
2, 2, 3;
2, 2, 3, 4;
2, 3, 2, 4, 5;
4, 2, 4, 2, 5, 6;
4, 2, 4, 5, 4, 6, 7;
2, 5, 2, 4, 6, 4, 7, 8;
2, 4, 6, 5, 2, 7, 2, 8, 9;
4, 2, 6, 7, 5, 6, 8, 2, 9, 10;
PROG
(PARI) isokap(sumap, nbap) = {for (d=1, sumap, fap = (sumap - (nbap-1)*nbap*d/2)/nbap; if (fap <= 0, return (0)); if (type(fap) == "t_INT", return (1)); ); return (0); }
a(n) = {if (n == 1, return (1)); forstep(len=n-1, 1, -1, if (isokap(n, len), return (len)); ); } \\ Michel Marcus, Jul 13 2014
CROSSREFS
Sequence in context: A104011 A242879 A176775 * A357039 A226182 A099774
KEYWORD
nonn,look
AUTHOR
John W. Layman, Sep 03 2010
STATUS
approved