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.

A081650 Least nonsquare whose remainder modulo k^2 is a square for all 0 < k <= n.

This page as a plain text file.
%I A081650 #25 Nov 21 2024 15:29:49
%S A081650 2,5,13,73,409,801,1584,2241,30601,30601,78409,156825,862416,862416,
%T A081650 7929009,28173825,196668004,196668004
%N A081650 Least nonsquare whose remainder modulo k^2 is a square for all 0 < k <= n.
%C A081650 See A260709 for the (maybe more natural) variant of squares (mod k^2) instead of remainders equal to a square. - _M. F. Hasler_, Nov 17 2015
%D A081650 Mark A. Herkommer, Number Theory, A Programmer's Guide, McGraw-Hill, New York, 1999, page 315.
%e A081650 a(3) = 13 because for (mod 1) (A000037) is the set of all nonsquares, for (mod 4) (A079896) is the set beginning {5, 8, 12, 13, 17, 20, 21, 24, 28, 29, ...} and for (mod 9) (A081642) is the set beginning {10, 13, 18, 19, 22, 27, 28, 31, 37, 40, ...}. The first element of the intersection of these three sets is 13.
%p A081650 M:= 0:
%p A081650 for m from 2 while M < 15 do
%p A081650    if (not issqr(m)) and andmap(issqr, [seq(m mod k^2, k=1..M+1)]) then
%p A081650        A[M+1]:= m;
%p A081650        for k from M+2 while issqr(m mod k^2) do A[k]:= m od:
%p A081650        M:= k-1;
%p A081650    fi
%p A081650 od:
%p A081650 seq(A[m],m=1..15); # _Robert Israel_, Nov 17 2015
%o A081650 (PARI) t=2; for(n=1,50, for(m=t,10^9, if(issquare(m), next); f=0; for(k=1,n,if(!issquare(m % k^2),f=1;break)); if(!f,print1(m","); t=m; break)))
%o A081650 (PARI) A081650(n,t=2)=for(m=t,9e9,issquare(m)&&next; for(k=1,n,issquare(m%k^2)||next(2));return(m)) \\ The 2nd optional arg allows us to give a lower search limit, useful since a(n+1) >= a(n) by definition: see usage below.
%o A081650 t=2;for(n=1,50, print1(t=A081650(n,t),",")) \\ _M. F. Hasler_, Nov 17 2015
%o A081650 (MATLAB)
%o A081650 N = 10^8;  % to get all terms <= N
%o A081650 B = ones(1,N);
%o A081650 B([1:floor(sqrt(N))].^2) = 0;
%o A081650 m = 1;
%o A081650 while true
%o A081650   nsq = ones(m^2,1);
%o A081650   nsq([1:m].^2)=0;
%o A081650   S = nsq * ones(1,ceil(N/m^2));
%o A081650   S = reshape(S,1,numel(S));
%o A081650   B(S(1:N)>0) = 0;
%o A081650   v = find(B,1,'first');
%o A081650   if numel(v) == 0
%o A081650     break
%o A081650   end
%o A081650   A(m) = v;
%o A081650   m = m + 1;
%o A081650 end
%o A081650 A  % _Robert Israel_, Nov 17 2015
%Y A081650 Cf. A000037, A079896, A081642, A081643, A081644, A081645, A081646, A081647, A081648, A081649.
%K A081650 nonn,more
%O A081650 1,1
%A A081650 _Robert G. Wilson v_, Mar 26 2003
%E A081650 Edited by _Ralf Stephan_, Mar 27 2003
%E A081650 Definition corrected and original PARI code updated by _M. F. Hasler_, Nov 17 2015
%E A081650 a(16) to a(18) from _Robert Israel_, Nov 17 2015