A068879 Duplicate of A030152.
1, 4, 9, 16, 25, 36, 49, 81, 121, 169, 256, 361, 529, 676, 729, 961, 1296, 4761, 5476
Offset: 1
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.
121 is alternating and in the sequence because its consecutive digits are odd-even-odd, 1 being odd and 2 even. Of course, 1234567890 is also alternating.
a030141 n = a030141_list !! (n-1) a030141_list = filter ((== 1) . a228710) [0..] -- Reinhard Zumkeller, Aug 31 2013
fQ[n_] := Block[{m = Mod[ IntegerDigits@ n, 2]}, m == Split[m, UnsameQ][[1]]]; Select[ Range[0, 130], fQ] (* Robert G. Wilson v, Apr 01 2011 *) Select[Range[0,150],FreeQ[Differences[Boole[EvenQ[IntegerDigits[#]]]],0]&] (* Harvey P. Dale, Jul 19 2025 *)
is(n,d=digits(n))=for(i=2,#d, if((d[i]-d[i-1])%2==0, return(0))); 1 \\ Charles R Greathouse IV, Jul 08 2022
from itertools import count def A030141_gen(startvalue=0): # generator of terms >= startvalue return filter(lambda n:all(int(a)+int(b)&1 for a, b in zip(str(n),str(n)[1:])),count(max(startvalue,0))) A030141_list = list(islice(A030141_gen(),30)) # Chai Wah Wu, Jul 12 2022
from itertools import chain, count, islice def altgen(seed, digits): allowed = "02468" if seed in "13579" else "13579" if digits == 1: yield from allowed; return for f in allowed: yield from (f + r for r in altgen(f, digits-1)) def agen(): yield from chain(range(10), (int(f+r) for d in count(2) for f in "123456789" for r in altgen(f, d-1))) print(list(islice(agen(), 65))) # Michael S. Branicky, Jul 12 2022
2129 is a term as 2, 1, 2 and 9 have even and odd parity alternately.
a030144 n = a030144_list !! (n-1) a030144_list = filter ((== 1) . a228710) a000040_list -- Reinhard Zumkeller, Aug 31 2013
Join[{2,3,5,7},Select[Prime[Range[400]],Union[Abs[Differences[Boole/@ EvenQ[ IntegerDigits[#]]]]] == {1}&]] (* Harvey P. Dale, Jul 26 2011 *)
1830 is a term as 1, 8, 3 and 0 have odd and even parity alternately.
altQ[n_] := n < 10 || Union[ Total /@ Partition[ Mod[ IntegerDigits@n, 2], 2, 1]] == {1}; t[n_] := n (n + 1)/2; Select[ t@ Range@ 400, altQ] (* Giovanni Resta, Aug 17 2018 *)
upto=2000;tfs=Flatten[Table[{True,False},{Ceiling[IntegerLength[ upto]]}]]; altparQ[n_]:= Module[{n2=n^2},MemberQ[Partition[ tfs,IntegerLength[n2],1], EvenQ/@IntegerDigits[n2]]]; Join[{0},Select[Range[upto],altparQ]] (* Harvey P. Dale, May 12 2011 *)
a030147 n = a030147_list !! (n-1) a030147_list = filter ((== 1) . a228710) a002113_list -- Reinhard Zumkeller, Aug 31 2013
palQ[n_, b_:10] := (IntegerDigits[n, b] == Reverse[IntegerDigits[n, b]]); alternParQ[n_, b_:10] := (Union[BlockMap[Xor @@ # &, OddQ[IntegerDigits[n, b]], 2, 1]] == {True}); Join[Range[0, 9], Select[Range[1000], palQ[#] && alternParQ[#] &]] (* Alonso del Arte, Feb 02 2020 *) Join[Range[0,9],Select[Range[100000],PalindromeQ[#]&&Union[Total/@Partition[Boole[ EvenQ[ IntegerDigits[ #]]],2,1]] =={1}&]] (* Harvey P. Dale, Jul 04 2023 *)
def isPal(n: Int) = (n.toString == n.toString.reverse) def alternsPar(n: Int): Boolean = { val dPars = Integer.toString(n).toList.map(_ % 2 == 0) val scanPars = (dPars zip dPars.tail).map{ case (x, y) => x ^ y } scanPars.toSet == Set(true) } (0 to 9) ++: (10 to 999).filter(isPal).filter(alternsPar) // Alonso del Arte, Feb 02 2020
altQ[n_] := n < 10 || Union[Total /@ Partition[ Mod[ IntegerDigits@n, 2], 2, 1]] == {1}; Select[ Range[0, 10^4]^3, altQ[#] &] (* Giovanni Resta, Aug 16 2018 *)
altQ[n_] := n < 10 || Union[Total /@ Partition[ Mod[ IntegerDigits@n, 2], 2, 1]] == {1}; Select[ Range[0, 10^5], altQ[#] && altQ[#^2] &] (* Giovanni Resta, Aug 16 2018 *)
pdaQ[n_]:=Module[{a=Mod[IntegerDigits[n],2],b=Mod[IntegerDigits[ Sqrt[ n]],2]},Length[ Split[a]] ==IntegerLength[n]&&Length[Split[b]]== IntegerLength[ Sqrt[n]]]; Join[{0},Select[Range[8500]^2,pdaQ]] (* Harvey P. Dale, Aug 05 2018 *)
alternating(n)={my(v=digits(n)%2);0==#select(i->v[i]==v[i-1],[2..#v])} { for(n=0, 10^5, if(alternating(n^2) && alternating(n), print1(n^2, ", "))) } \\ Andrew Howroyd, Aug 05 2018
\\ for larger n: requires alternating function above upto(n)={local(R=List([0])); my(recurse(s,b)=if(b0&&alternating(k^2\b), listput(R, k)); self()(k, 10*b)))))); recurse(0,1); listsort(R); Vec(R)} apply(n->n^2, upto(sqrtint(10^12))) \\ Andrew Howroyd, Aug 05 2018
altQ[n_] := n < 10 || Union[Total /@ Partition[ Mod[ IntegerDigits@n, 2], 2, 1]] == {1}; Select[ Range[1, 2000, 2]^2, altQ[#] &] (* Giovanni Resta, Aug 16 2018 *)
Comments