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.

A128201 Union of positive squares and the odd numbers.

This page as a plain text file.
%I A128201 #43 Oct 02 2024 14:46:38
%S A128201 1,3,4,5,7,9,11,13,15,16,17,19,21,23,25,27,29,31,33,35,36,37,39,41,43,
%T A128201 45,47,49,51,53,55,57,59,61,63,64,65,67,69,71,73,75,77,79,81,83,85,87,
%U A128201 89,91,93,95,97,99,100,101,103,105,107,109,111,113,115,117,119,121,123
%N A128201 Union of positive squares and the odd numbers.
%C A128201 Range of A128200.
%C A128201 Positive numbers n such that n^((1 + n)/2) is an integer. - _Gionata Neri_, May 07 2016
%H A128201 R. Zumkeller, <a href="/A128201/b128201.txt">Table of n, a(n) for n = 1..10000</a>
%F A128201 a(n) = f(n,1,1,2), where f(n,i,m,x) = if i=n then m; else if m+1=x^2 then f(n,i+1,m+1,x); else if m+1>x^2 then f(n,i+1,m+1,x+2); else f(n,i+1,m+2,x).
%F A128201 Set R(n) = 2*n - round(sqrt(2*n)); then a(n) = R(n) + sign(frac(sqrt(R(n)))) * (not(R(n) mod 2)). - _Gerald Hillier_, Apr 16 2015
%t A128201 f[n_] := Block[{s = Range[n]^2, t}, Union[s, Range[1, Last@ s, 2]] // Sort]; f@ 12 (* _Michael De Vlieger_, Apr 16 2015 *)
%o A128201 (PARI) A128201(n)=!(bittest(n=2*n-round(sqrt(2*n)),0)||issquare(n))+n \\ Based on Hiliers's formula. - _M. F. Hasler_, Apr 19 2015
%o A128201 (PARI) is_A128201(n)=bittest(n,0)||issquare(n) \\ _M. F. Hasler_, Apr 19 2015
%o A128201 (Python)
%o A128201 from math import isqrt
%o A128201 def A128201(n):
%o A128201     def f(x): return n+(x>>1)-(isqrt(x)>>1)
%o A128201     m, k = n, f(n)
%o A128201     while m != k: m, k = k, f(k)
%o A128201     return m # _Chai Wah Wu_, Oct 02 2024
%Y A128201 Partial sums given by A157130. - _Gerald Hillier_, Feb 25 2009
%Y A128201 See A176693 for the union of even numbers and the squares. - _M. F. Hasler_, Apr 19 2015
%Y A128201 Cf. A157502, A157512.
%K A128201 nonn,easy
%O A128201 1,2
%A A128201 _Reinhard Zumkeller_, Mar 04 2007