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-7 of 7 results.

A030141 Numbers in which parity of the decimal digits alternates.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 21, 23, 25, 27, 29, 30, 32, 34, 36, 38, 41, 43, 45, 47, 49, 50, 52, 54, 56, 58, 61, 63, 65, 67, 69, 70, 72, 74, 76, 78, 81, 83, 85, 87, 89, 90, 92, 94, 96, 98, 101, 103, 105, 107, 109, 121, 123, 125, 127, 129
Offset: 1

Views

Author

Keywords

Comments

An alternating integer is a positive integer for which, in base-10, the parity of its digits alternates.
The number of terms < 10^n (n>=0): 1, 10, 55, 280, 1405, 7030, 35155, ..., . - Robert G. Wilson v, Apr 01 2011
The number of terms between 10^n and 10^(n+1) is 9 * 5^n for n>=0. For n>=0, number of terms < 10^n is 1 + 9 * (5^n-1)/4. - Franklin T. Adams-Watters, Apr 01 2011
A228710(a(n)) = 1. - Reinhard Zumkeller, Aug 31 2013

Examples

			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.
		

Crossrefs

Programs

  • Haskell
    a030141 n = a030141_list !! (n-1)
    a030141_list = filter ((== 1) . a228710) [0..]
    -- Reinhard Zumkeller, Aug 31 2013
    
  • Mathematica
    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 *)
  • PARI
    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
    
  • Python
    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
    
  • Python
    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

Extensions

Offset corrected by Reinhard Zumkeller, Aug 31 2013

A030152 Squares in which parity of digits alternates.

Original entry on oeis.org

0, 1, 4, 9, 16, 25, 36, 49, 81, 121, 169, 256, 361, 529, 676, 729, 961, 1296, 4761, 5476, 6561, 7056, 9216, 12321, 12769, 14161, 16129, 18769, 32761, 34969, 41616, 56169, 69696, 72361, 74529, 76729, 78961, 87616, 96721, 147456, 163216, 181476, 212521
Offset: 1

Views

Author

Keywords

Examples

			1296 is a term as 1, 2, 9 and 6 have odd and even parity alternately.
		

Crossrefs

Programs

  • Haskell
    a030152 n = a030152_list !! (n-1)
    a030152_list = filter ((== 1) . a228710) a000290_list
    -- Reinhard Zumkeller, Aug 31 2013
  • Maple
    i := 0:for a from 1 to 1000 do b := a^2:g := ceil(log(b+1)/log(10)):iss := true:for j from 1 to g-1 do if((b mod 2)=1) then if((floor(b/10^j) mod 2)=((-1)^(j+1)+1)/2) then iss := false:end if:else if((floor(b/10^j) mod 2)=((-1)^j+1)/2) then iss := false:end if:end if:end do: if(iss=true) then i := i+1:c[i] := b:end if:end do:q := seq(c[k],k=1..i-1); # Sascha Kurz, Mar 23 2002
  • Mathematica
    altQ[n_] := n < 10 || Union[Total /@ Partition[ Mod[ IntegerDigits@n, 2], 2, 1]] == {1}; Select[ Range[0, 500]^2, altQ[#] &] (* Giovanni Resta, Aug 16 2018 *)

Formula

A010052(a(n)) * A228710(a(n)) = 1. - Reinhard Zumkeller, Aug 31 2013

Extensions

Edited by N. J. A. Sloane, Aug 31 2009 at the suggestion of R. J. Mathar
Offset corrected by Reinhard Zumkeller, Aug 31 2013

A030144 Primes in which parity of digits alternates.

Original entry on oeis.org

2, 3, 5, 7, 23, 29, 41, 43, 47, 61, 67, 83, 89, 101, 103, 107, 109, 127, 149, 163, 167, 181, 307, 347, 349, 367, 383, 389, 503, 509, 521, 523, 541, 547, 563, 569, 587, 701, 709, 727, 743, 761, 769, 787, 907, 929, 941, 947, 967, 983, 2129, 2141, 2143, 2161, 2309
Offset: 1

Views

Author

Keywords

Examples

			2129 is a term as 2, 1, 2 and 9 have even and odd parity alternately.
		

Crossrefs

Intersection of A000040 and A030141.

Programs

  • Haskell
    a030144 n = a030144_list !! (n-1)
    a030144_list = filter ((== 1) . a228710) a000040_list
    -- Reinhard Zumkeller, Aug 31 2013
  • Mathematica
    Join[{2,3,5,7},Select[Prime[Range[400]],Union[Abs[Differences[Boole/@ EvenQ[ IntegerDigits[#]]]]] == {1}&]] (* Harvey P. Dale, Jul 26 2011 *)

Formula

A010051(a(n)) * A228710(a(n)) = 1. - Reinhard Zumkeller, Aug 31 2013

Extensions

Offset corrected by Reinhard Zumkeller, Aug 31 2013

A030142 Odd numbers in which parity of digits alternates.

Original entry on oeis.org

1, 3, 5, 7, 9, 21, 23, 25, 27, 29, 41, 43, 45, 47, 49, 61, 63, 65, 67, 69, 81, 83, 85, 87, 89, 101, 103, 105, 107, 109, 121, 123, 125, 127, 129, 141, 143, 145, 147, 149, 161, 163, 165, 167, 169, 181, 183, 185, 187, 189, 301, 303, 305, 307, 309, 321, 323
Offset: 1

Views

Author

Keywords

Comments

a(n) = A179085(n) for n <= 25. - Reinhard Zumkeller, Jun 28 2010

Crossrefs

Cf. A030143, A062285, intersection of A005408 and A030141.

Programs

  • Haskell
    a030142 n = a030142_list !! (n-1)
    a030142_list = filter odd a030141_list
    -- Reinhard Zumkeller, Aug 31 2013
  • Mathematica
    id[n_]:=IntegerDigits[n];t={}; Do[If[Length[id[n]]==1, AppendTo[t,n], If[Union[Abs[Differences[Boole /@ EvenQ[id[n]]]]] == {1}, AppendTo[t,n]]], {n,1,323,2}]; t (* Jayanta Basu, May 07 2013 *)
    Join[{1, 3, 5, 7, 9}, Select[Range[21, 323, 2], Total[Abs[Differences[Mod[(id = IntegerDigits[#]), 2]]]] == Length[id] - 1 &]] (* Zak Seidov, May 07 2013 *)

Formula

(a(n) mod 2) * A228710(a(n)) = 1. - Reinhard Zumkeller, Aug 31 2013

Extensions

Offset corrected by Reinhard Zumkeller, Jun 28 2010

A030147 Palindromes in which parity of digits alternates.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 101, 121, 141, 161, 181, 212, 232, 252, 272, 292, 303, 323, 343, 363, 383, 414, 434, 454, 474, 494, 505, 525, 545, 565, 585, 616, 636, 656, 676, 696, 707, 727, 747, 767, 787, 818, 838, 858, 878, 898, 909, 929, 949
Offset: 1

Views

Author

Keywords

Comments

All terms have an odd number of digits. - Alonso del Arte, Jan 31 2020

Crossrefs

Intersection of A002113 and A030141.
Subsequence of A001633.

Programs

  • Haskell
    a030147 n = a030147_list !! (n-1)
    a030147_list = filter ((== 1) . a228710) a002113_list
    -- Reinhard Zumkeller, Aug 31 2013
    
  • Mathematica
    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 *)
  • Scala
    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

Formula

A136522(a(n)) * A228710(a(n)) = 1. - Reinhard Zumkeller, Aug 31 2013

A062285 Numbers with the most significant digit even and alternating parity of digits.

Original entry on oeis.org

0, 2, 4, 6, 8, 21, 23, 25, 27, 29, 41, 43, 45, 47, 49, 61, 63, 65, 67, 69, 81, 83, 85, 87, 89, 210, 212, 214, 216, 218, 230, 232, 234, 236, 238, 250, 252, 254, 256, 258, 270, 272, 274, 276, 278, 290, 292, 294, 296, 298, 410, 412, 414, 416, 418, 430, 432, 434, 436
Offset: 1

Views

Author

Amarnath Murthy, Jun 18 2001

Keywords

Examples

			4325 is a member as the most significant digit is 4 (even) and the subsequent digits 3, 2, 5 are alternately odd and even.
		

Crossrefs

Programs

  • Haskell
    a062285 n = a062285_list !! (n-1)
    a062285_list = filter (even . a000030) a030141_list
    -- Reinhard Zumkeller, Aug 31 2013

Formula

(1 - A000030(a(n)) mod 2) * A228710(a(n)) = 1. - Reinhard Zumkeller, Aug 31 2013

Extensions

Corrected and extended by Larry Reeves (larryr(AT)acm.org), Jun 19 2001
Offset corrected by and a(1)=0 prepended by Reinhard Zumkeller, Aug 31 2013

A376692 Numbers with the most significant digit odd and alternating parity of digits.

Original entry on oeis.org

1, 3, 5, 7, 9, 10, 12, 14, 16, 18, 30, 32, 34, 36, 38, 50, 52, 54, 56, 58, 70, 72, 74, 76, 78, 90, 92, 94, 96, 98, 101, 103, 105, 107, 109, 121, 123, 125, 127, 129, 141, 143, 145, 147, 149, 161, 163, 165, 167, 169, 181, 183, 185, 187, 189, 301, 303, 305, 307, 309
Offset: 1

Views

Author

Andrew Howroyd, Oct 01 2024

Keywords

Crossrefs

Complement of A062285 within A030141.

Programs

  • PARI
    isok(n)=my(d=digits(n)); for(i=1, #d, if((d[i]-i)%2, return(0))); 1
Showing 1-7 of 7 results.