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.

A068880 Smallest n-digit square with property that digits alternate in parity.

This page as a plain text file.
%I A068880 #18 Mar 21 2024 06:49:31
%S A068880 1,16,121,1296,12321,147456,1038361,10929636,103652761,1010985616,
%T A068880 10327234129,101070583056,1010163694761,10107210905856,
%U A068880 101030903296569,1012923810743296,10101430507492129,101034169694343076,1010167692929438121,10101478149656965696
%N A068880 Smallest n-digit square with property that digits alternate in parity.
%H A068880 Sean A. Irvine, <a href="/A068880/b068880.txt">Table of n, a(n) for n = 1..53</a> (terms 1..33 from Giovanni Resta)
%e A068880 a(4) = 1296 as 1, 2, 9 and 6 have odd and even parity alternately.
%t A068880 altQ[n_] := n < 10 || Union[ Total /@ Partition[ Mod[ IntegerDigits@n, 2], 2, 1]] == {1}; a[n_] := Block[{r = Ceiling@ Sqrt@ FromDigits[ Mod[Range@ n, 2]]}, While[! altQ[r^2], r++]; r^2]; Array[a, 16] (* _Giovanni Resta_, Aug 17 2018 *)
%o A068880 (Python)
%o A068880 from math import isqrt
%o A068880 from itertools import count, islice
%o A068880 def allalt(s):
%o A068880     es, os, e, o = set(s[::2]), set(s[1::2]), set("02468"), set("13579")
%o A068880     return (es <= o and os <= e) or (es <= e and os <= o)
%o A068880 def a(n):
%o A068880     r = isqrt(int(("10"*n)[:n]))
%o A068880     while len(s:=str(r*r)) < n or not allalt(s): r += 1
%o A068880     return int(s)
%o A068880 print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Mar 21 2024
%Y A068880 Cf. A068881, A030152, A068876.
%K A068880 base,nonn
%O A068880 1,2
%A A068880 _Amarnath Murthy_, Mar 19 2002
%E A068880 More terms from _Sascha Kurz_, Mar 23 2002
%E A068880 a(14)-a(20) from _Giovanni Resta_, Aug 17 2018