OFFSET
1,2
COMMENTS
Since this is a sequence with 3 indexes (n,p,q), then the order proposed is an ordering by planes of 3D-discrete points (similar to a diagonal ordering of 2D-discrete points). It is not possible to order by rows, columns since n, p, q are boundless.
FORMULA
a(n, p, q) = Sum_{k=1..n} floor(k*p/q) defines the sequence.
a(n, p, q) = n*(n+1)*p/q/2 - floor(n/q) * (q-1)/2 - Sum_{k=1...(n mod q)} (k*p mod q)/q (the remaining sum has at most q-1 terms, and can assume at most q values when n varies, i.e., that sum for n is equal to the sum for n+q, so the computation of a(n, p, q) requires adding at most (q+1) terms). [Renzo Benedetti, Jul 27 2012]
EXAMPLE
a(n, 1, 3) = n*(n+1)/ 6 - floor(n/3) - Sum_{k=1..(n mod 3)} (k mod 3) = n*(n+1)/ 6 - floor(n/3) - (4 mod 3)/3 = A130518(n).
Example of the ordering (n,p,q): (1,1,1), (1,1,2), (1,2,1), (2,1,1), (1,1,3), (1,3,1), (2,1,2), (2,2,1), (3,1,1), (1,1,4), ...
CROSSREFS
KEYWORD
nonn
AUTHOR
Renzo Benedetti, Jul 27 2012
STATUS
approved