OFFSET
1,3
COMMENTS
Equivalently, largest k < n such that k-th triangular number (A000217(k)) is a multiple of n, or 0 if no such k exists.
FORMULA
a(2n-1) = 2n-2 for all n >= 1; a(2^n) = 0 for all n >= 1.
PROG
(PARI) {a(n) = s=0; saved_k=0; k=0; while(k<n-1, k++; s=s+(n-k); if(s%n==0, saved_k=k)); saved_k}
CROSSREFS
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Jun 05 2004
EXTENSIONS
Edited by Rick L. Shepherd, Jun 08 2004
STATUS
approved