OFFSET
1,3
COMMENTS
This is a fractal sequence: if the first instance of each number is deleted, the original sequence is recovered. - Franklin T. Adams-Watters, Dec 14 2013
Subsequences start at indices A000330 + 1. - Ralf Stephan, Dec 17 2013
When sequence fills a triangular array by rows, the main diagonal is A064865.
LINKS
Zhuorui He, Table of n, a(n) for n=1..22140.
FORMULA
For 1 <= n <= 650, a(n) = n - t*(t-1)*(2t-1)/6, where t = floor((3*n)^(1/3)+1/2). - Mikael Aaltonen, Jan 17 2015
a(n) = n - k*(k-1)*(2k-1)/6 where k = m+1 if n>m*(m+1)*(2m+1)/6 and k = m otherwise and m = floor((3n)^(1/3)). - Chai Wah Wu, Nov 05 2024
EXAMPLE
The table begins:
1;
1, 2, 3, 4;
1, 2, 3, 4, 5, 6, 7, 8, 9;
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16;
Row n has n^2 terms.
As a regular triangle the sequence begins:
1
1 2
3 4 1
2 3 4 5
6 7 8 9 1
...
From Antti Karttunen, Feb 17 2014: (Start)
The sequence can also be considered as an irregular table consisting of successively larger square matrices:
1;
1, 2;
3, 4;
1, 2, 3;
4, 5, 6;
7, 8, 9;
1, 2, 3, 4;
5, 6, 7, 8;
9,10,11,12;
13,14,15,16;
etc.
(End)
MATHEMATICA
Table[Range[n^2], {n, 10}]//Flatten (* Harvey P. Dale, Mar 05 2018 *)
PROG
(PARI) A064866_vec(N=9)=concat(vector(N, i, vector(i^2, j, j))) \\ Note: This creates a vector; use A064866_vec()[n] to get the n-th term. - M. F. Hasler, Feb 17 2014
(Python)
from sympy import integer_nthroot
def A064866(n): return n-(k:=(m:=integer_nthroot(3*n, 3)[0])+(6*n>m*(m+1)*((m<<1)+1)))*(k-1)*((k<<1)-1)//6 # Chai Wah Wu, Nov 04 2024
CROSSREFS
KEYWORD
easy,nonn,tabf
AUTHOR
Floor van Lamoen, Oct 08 2001
EXTENSIONS
Edited by Ralf Stephan, Dec 17 2013
Keyword tabf from Michel Marcus, Sep 09 2025
Revised by Zhuorui He and Sean A. Irvine, Nov 05 2025
STATUS
approved
