cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A351319 a(n) = floor(n/k), where k is the nearest square to n.

This page as a plain text file.
%I A351319 #32 Mar 26 2022 02:40:56
%S A351319 1,2,0,1,1,1,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,
%T A351319 0,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,
%U A351319 1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1
%N A351319 a(n) = floor(n/k), where k is the nearest square to n.
%C A351319 For all n != 2, a(n) is 0 when less than the nearest square, A053187(n), and is 1 otherwise.
%C A351319 From _Jon E. Schoenfield_, Mar 22 2022: (Start)
%C A351319 After the first two terms, the sequence consists of runs of 0's and 1's, with run lengths 1,3,2,4,3,5,4,6,5,7,6,8,... = A028242.
%C A351319 For m >= 1, there are 2m integers k whose nearest square is m^2, namely, the m-1 integers (in the interval [m^2-m+1, m^2-1]) for which k < m^2 (hence a(k) = 0), followed by the m+1 integers (in the interval [m^2, m^2+m]) for which k >= m^2 (hence a(k) = 1). (End)
%F A351319 a(n) = floor(n/k), where k = round(sqrt(n))^2 = A053187(n).
%F A351319 a(n) = A267708(n) for n != 2.
%e A351319 a(5) = floor(5/4) = 1.
%t A351319 Table[Floor[n/Round[Sqrt[n]]^2], {n, 100}] (* _Wesley Ivan Hurt_, Mar 18 2022 *)
%o A351319 (Python)
%o A351319 import math
%o A351319 def a(n):
%o A351319     k = math.isqrt(n)
%o A351319     if n - k**2 > k: k += 1
%o A351319     return n // k**2;
%o A351319 for n in range(1, 101):
%o A351319     print("{}, ".format(a(n)), end="")
%o A351319 (Python)
%o A351319 from math import isqrt
%o A351319 def A351319(n): return n if n <= 2 else int((k:=isqrt(n))**2+k-n+1 > 0) # _Chai Wah Wu_, Mar 26 2022
%o A351319 (PARI) a(n) = if(n==2,2, my(r,s=sqrtint(n,&r)); r<=s); \\ _Kevin Ryde_, Mar 23 2022
%Y A351319 Cf. A000194, A053187 (nearest square), A028242 (run lengths).
%Y A351319 Cf. A267708 (essentially the same).
%K A351319 nonn,easy
%O A351319 1,2
%A A351319 _Joelle H. Kassir_, Mar 18 2022