A053615 Pyramidal sequence: distance to nearest product of two consecutive integers (promic or heteromecic numbers).
0, 1, 0, 1, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7
Offset: 0
Examples
a(10) = |10 - 3*4| = 2. From _Boris Putievskiy_, Jan 29 2013: (Start) The start of the sequence as table: 0, 1, 2, 3, 4, 5, 6, 7, ... 1, 0, 1, 2, 3, 4, 5, 6, ... 2, 1, 0, 1, 2, 3, 4, 5, ... 3, 2, 1, 0, 1, 2, 3, 4, ... 4, 3, 2, 1, 0, 1, 2, 3, ... 5, 4, 3, 2, 1, 0, 1, 2, ... 6, 5, 4, 3, 2, 1, 0, 1, ... ... The start of the sequence as triangle array read by rows: 0; 1, 0, 1; 2, 1, 0, 1, 2; 3, 2, 1, 0, 1, 2, 3; 4, 3, 2, 1, 0, 1, 2, 3, 4; 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5; 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6; 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7; ... Row number r contains 2*r-1 numbers: r-1, r-2, ..., 0, 1, 2, ..., r-1. (End)
Links
- Harvey P. Dale, Table of n, a(n) for n = 0..1000
- Boris Putievskiy, Transformations [of] Integer Sequences And Pairing Functions arXiv:1212.2732 [math.CO], 2012.
- Index entries for sequences related to distance to nearest element of some set
Programs
-
Maple
A053615 := proc(n) A004738(n+1)-1 ; # reuses code of A004738 end proc: seq(A053615(n),n=0..30) ; # R. J. Mathar, Feb 14 2019
-
Mathematica
a[0] = 0; a[n_] := Floor[Sqrt[n]] - a[n - Floor[Sqrt[n]]]; Table[a[n], {n, 0, 103}] (* Jean-François Alcover, Dec 16 2011, after Benoit Cloitre *) Join[{0},Module[{nn=150,ptci},ptci=Times@@@Partition[Range[nn/2+1],2,1];Table[Abs[n-Nearest[ptci,n]],{n,nn}][[All,1]]]] (* Harvey P. Dale, Aug 29 2020 *)
-
PARI
a(n)=sqrtint(n)-a(n-sqrtint(n))
-
PARI
apply( {A053615(n)=(t=sqrt(n)\/1)-abs(t^2-n)}, [0..99]) \\ M. F. Hasler, Feb 01 2025
-
Python
A053615 = lambda n: (t := round(n**.5)) - abs(t**2 - n) # M. F. Hasler, Feb 01 2025
-
Python
from math import isqrt def A053615(n): return abs((t:=isqrt(n))*(t+1)-n) # Chai Wah Wu, Mar 01 2025
Formula
a(n) = A004738(n+1) - 1.
Let u(1)=1, u(n) = n - u(n-sqrtint(n)) (cf. A037458); then a(0)=0 and for n > 0 a(n) = 2*u(n) - n. - Benoit Cloitre, Dec 22 2002
a(0)=0 then a(n) = floor(sqrt(n)) - a(n - floor(sqrt(n))). - Benoit Cloitre, May 03 2004
a(n) = |A196199(n)|. a(n) = |n - t^2 - t|, where t = floor(sqrt(n)). - Boris Putievskiy, Jan 29 2013 [corrected by Ridouane Oudra, May 11 2019]
a(n) = A000194(n) - A053188(n) = t - |t^2 - n|, where t = floor(sqrt(n)+1/2). - Ridouane Oudra, May 11 2019
Comments