login
A227179
After initial 0, integers from 0 to n(n-1) followed by integers from 0 to n(n+1) and so on.
5
0, 0, 0, 1, 2, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
OFFSET
0,5
LINKS
FORMULA
a(n) = n - (1 + A006527(A227177(n)-1)).
MATHEMATICA
Flatten[(Range[(#-2) (#-1)+1]-1&)[Range[7]]] (* Peter J. C. Moses, Jul 11 2013 *)
PROG
(Scheme): (define (A227179 n) (- n (+ 1 (A006527 (- (A227177 n) 1)))))
(Python)
from sympy import integer_nthroot
def A227179(n): return n-1-(f:=lambda x:x*(x**2+2))((m:=integer_nthroot(k:=3*n, 3)[0])-(k<=f(m)))//3 # Chai Wah Wu, Nov 07 2024
CROSSREFS
KEYWORD
nonn,changed
AUTHOR
Antti Karttunen, Jul 03 2013
STATUS
approved