login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(1)=1; for n>1, a(n) is the smallest number k > a(n-1) such that a(n-1) + k is not a square.
1

%I #24 Oct 02 2024 01:57:28

%S 1,2,3,4,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,26,27,28,

%T 29,30,31,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,

%U 53,54,55,56,57,58,59,60,62,63,64,65,66,67,68,69,70,71,72,73,74,75

%N a(1)=1; for n>1, a(n) is the smallest number k > a(n-1) such that a(n-1) + k is not a square.

%C Complement of A099776.

%F For n>1, a(n) = n+m if n>m(2m+1)+1 and a(n) = n+m-1 otherwise where m = floor(sqrt(n/2)). - _Chai Wah Wu_, Oct 01 2024

%e 5 is not a term because 4 + 5 = 9 = 3^2.

%t a[1] = 1; a[n_] := a[n] = Module[{k = a[n - 1] + 1}, While[IntegerQ[Sqrt[a[n - 1] + k]], k++]; k]; Array[a, 100] (* _Amiram Eldar_, Jan 14 2022 *)

%o (PARI) lista(nn) = {my(x=1, list=List(x)); for (n=2, nn, my(k=x+1); while (issquare(x+k), k++); listput(list, k); x = k;); list;} \\ _Michel Marcus_, Jan 14 2022

%o (Python)

%o from math import isqrt

%o def A350757(n): return n+(m:=isqrt(n>>1))-int(n<=m*((m<<1)+1)+1) if n>1 else 1 # _Chai Wah Wu_, Oct 01 2024

%Y Cf. A099776.

%K nonn

%O 1,2

%A _J. Lowell_, Jan 13 2022