login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A256243 Smallest positive integer m such that n + 2m is a square. 4
4, 1, 3, 6, 2, 5, 1, 4, 8, 3, 7, 2, 6, 1, 5, 10, 4, 9, 3, 8, 2, 7, 1, 6, 12, 5, 11, 4, 10, 3, 9, 2, 8, 1, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 16, 7, 15, 6, 14, 5, 13, 4, 12, 3, 11, 2, 10, 1, 9, 18, 8, 17, 7, 16, 6, 15, 5, 14, 4, 13, 3, 12, 2, 11, 1, 10, 20, 9, 19, 8, 18, 7, 17, 6, 16, 5, 15, 4, 14, 3, 13, 2, 12, 1, 11, 22 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
FORMULA
1 <= a(n) <= 2*sqrt(n) + 2. - Charles R Greathouse IV, Mar 23 2015
a(n) = (1/4)*(6*floor(sqrt(n)) + 2*floor(sqrt(n))^2 + (2*floor(sqrt(n)) + 3)*(-1)^(n - floor(sqrt(n))) - 2*n + 5). - Ridouane Oudra, Oct 09 2020
EXAMPLE
1 + 2*4 = 9 = 3^2 so a(1) = 4.
2 + 2*1 = 4 = 2^2, so a(2) = 1.
3 + 2*3 = 9 = 3^2, so a(3) = 3.
MATHEMATICA
Table[m = 1; While[! IntegerQ[Sqrt[n + 2*m]], m++]; m, {n, 100}] (* Michael De Vlieger, Mar 20 2015 *)
PROG
(PARI) a(n)=m=1; while(!issquare(n+2*m), m++); m
vector(100, n, a(n)) \\ Derek Orr, Mar 22 2015
(PARI) a(n)=my(s=sqrtint(n)); (if((s-n)%2, s+1, s+2)^2-n)/2 \\ Charles R Greathouse IV, Mar 23 2015
CROSSREFS
Sequence in context: A299616 A134224 A121441 * A190479 A074813 A151861
KEYWORD
nonn,easy
AUTHOR
Zak Seidov, Mar 20 2015
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 12 06:13 EDT 2024. Contains 371623 sequences. (Running on oeis4.)