login
A350757
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
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, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75
OFFSET
1,2
COMMENTS
Complement of A099776.
FORMULA
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
EXAMPLE
5 is not a term because 4 + 5 = 9 = 3^2.
MATHEMATICA
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 *)
PROG
(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
(Python)
from math import isqrt
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
CROSSREFS
Cf. A099776.
Sequence in context: A013919 A101771 A035058 * A004776 A187945 A137409
KEYWORD
nonn
AUTHOR
J. Lowell, Jan 13 2022
STATUS
approved