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.

Showing 1-1 of 1 results.

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

Original entry on oeis.org

1, 16, 121, 1296, 12321, 147456, 1038361, 10929636, 103652761, 1010985616, 10327234129, 101070583056, 1010163694761, 10107210905856, 101030903296569, 1012923810743296, 10101430507492129, 101034169694343076, 1010167692929438121, 10101478149656965696
Offset: 1

Views

Author

Amarnath Murthy, Mar 19 2002

Keywords

Examples

			a(4) = 1296 as 1, 2, 9 and 6 have odd and even parity alternately.
		

Crossrefs

Programs

  • Mathematica
    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 *)
  • Python
    from math import isqrt
    from itertools import count, islice
    def allalt(s):
        es, os, e, o = set(s[::2]), set(s[1::2]), set("02468"), set("13579")
        return (es <= o and os <= e) or (es <= e and os <= o)
    def a(n):
        r = isqrt(int(("10"*n)[:n]))
        while len(s:=str(r*r)) < n or not allalt(s): r += 1
        return int(s)
    print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Mar 21 2024

Extensions

More terms from Sascha Kurz, Mar 23 2002
a(14)-a(20) from Giovanni Resta, Aug 17 2018
Showing 1-1 of 1 results.