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

A180094 Number of steps to reach 0 or 1, starting with n and applying the map k -> (number of 1's in binary expansion of k) repeatedly.

Original entry on oeis.org

0, 0, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 2, 1, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 2, 3, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 2, 3, 2, 2, 3, 2, 3, 3, 2, 3, 2, 2, 3, 3, 2, 2, 3, 2, 3, 3, 3, 1, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 2, 3, 2, 2, 3, 2, 3, 3, 2, 3, 2, 2, 3, 3, 2, 2, 3, 2, 3, 3, 3, 2, 3, 3, 2, 3
Offset: 0

Views

Author

Joerg Arndt, Jan 15 2011

Keywords

Comments

The number of 1's in binary expansion of n is called the binary weight (or Hamming weight) of n, A000120(n).
a(n)=0 for n=0 and n=1; a(n)=1 for powers of 2.
Records appear for n = 2, 3, 7, 127=2^7-1, 2^127-1, ... (terms of A007013).
It appears that the indices of the even terms for n>0 are sequence A075311.

Crossrefs

One less than A078627.

Programs

  • Haskell
    a180094 n = snd $ until ((< 2) . fst) (\(x, c) -> (a000120 x, c+1)) (n,0)
    -- Reinhard Zumkeller, Apr 22 2011
    
  • Magma
    Countbits:=func< n | &+Intseq(n, 2) >;
    StepsTo01:=function(n); s:=0; k:=n; while k gt 1 do k:=Countbits(k); s+:=1; end while; return s; end function;
    [ StepsTo01(n): n in [0..105] ]; // Klaus Brockhaus, Jan 15 2011
    
  • Maple
    a:= n-> `if`(n<2, 0, 1 + a(add(i, i=convert(n, base, 2)))):
    seq(a(n), n=0..100);  # Alois P. Heinz, Jan 15 2011
  • Mathematica
    Table[Length[NestWhileList[DigitCount[#,2,1]&,n,#>1&]]-1,{n,0,100}] (* Harvey P. Dale, Jul 27 2012 *)
  • PARI
    bitcount(x)=
    { /* Return Hamming weight of x, i.e. A000120(x) */
        local(p);  p = 0;
        while ( x, p+=bitand(x, 1); x>>=1; );
        return( p );
    }
    X(n)=
    { /* Return how many iterations of bitcount() are needed to reach 0 or 1 */
        if ( n<=1, return(0) );
        return( 1+X(bitcount(n)) );
    }
    { for (n=0, 100, print1(X(n),", ") ); } /* print terms of sequence */
    
  • Python
    def a(n):
        c = 1 if n > 1 else 0
        while (n:=n.bit_count()) > 1:
            c += 1
        return c
    print([a(n) for n in range(101)]) # Michael S. Branicky, Mar 12 2025

A217122 a(n) = (number of 1's in binary expansion of n)th positive number not among the previous terms.

Original entry on oeis.org

1, 2, 4, 3, 6, 7, 9, 5, 10, 11, 13, 12, 15, 16, 18, 8, 17, 19, 21, 20, 23, 24, 26, 22, 27, 28, 30, 29, 32, 33, 35, 14, 31, 34, 37, 36, 39, 40, 42, 38, 43, 44, 46, 45, 48, 49, 51, 41, 50, 52, 54, 53, 56, 57, 59, 55, 60, 61, 63, 62, 65, 66, 68, 25, 58, 64, 69, 67, 71, 72, 74, 70, 75, 76, 78, 77, 80, 81, 83, 73, 82, 84, 86, 85, 88, 89, 91, 87, 92
Offset: 1

Views

Author

Paul Tek, Mar 16 2013

Keywords

Comments

This is a permutation of the positive numbers.

Examples

			3 has 2 1's in its binary expansion, and the 2nd positive number not among the previous terms is 4; hence a(3)=4
		

Crossrefs

Cf. A000120: number of 1's in binary expansion of n.
Cf. A225589 (inverse), A075311.

Programs

  • Haskell
    import Data.List (delete)
    a217122 n = a217122_list !! (n-1)
    a217122_list = f 1 [0..] where
       f x zs = y : f (x + 1) (delete y zs) where
         y = zs !! a000120 x
    -- Reinhard Zumkeller, May 11 2013

A075517 Created by removing all integers which take an odd number of nested digit sums to reach <10.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 28, 29, 37, 38, 39, 46, 47, 48, 49, 55, 56, 57, 58, 59, 64, 65, 66, 67, 68, 69, 73, 74, 75, 76, 77, 78, 79, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 109, 118, 119, 127, 128, 129, 136, 137, 138, 139, 145, 146, 147
Offset: 0

Views

Author

Jon Perry, Oct 11 2002

Keywords

Examples

			18 -> 1+8 = 9. This takes 1 step to be reduced to a single integer, hence is not in the sequence. 99 -> 9+9 = 18, takes 2 steps and so is in the sequence.
		

Crossrefs

Programs

  • Haskell
    a075517 n = a075517_list !! n
    a075517_list = [0..9] ++ f 1 [0..9] where
       f x ys = if a007953 x `elem` ys then f (x + 1) ys
                                       else x : f (x + 1) (x : ys)
    -- Reinhard Zumkeller, Sep 29 2014, Apr 22 2012
  • Mathematica
    ondQ[n_]:=OddQ[Length[NestWhileList[Total[IntegerDigits[#]]&,n,#>9&]]]; Select[Range[0,200],ondQ] (* Harvey P. Dale, Dec 22 2016 *)
  • PARI
    sumdigits(n)=local(c); c=0; while (n>0,c=c+n%10; n=n-n%10; n=n/10); c checkSieve(n)=local(c); c=0; while(n>9, n=sumdigits(n); c++); 1-c%2 for (n=1,2000,if (checkSieve(n),print1(n,",")))
    

Extensions

Offset fixed by Reinhard Zumkeller, Apr 22 2012
Added a(0) = 0. - Jon Perry, Nov 28 2012

A079495 Numbers k such that the sum of the squares of the digits of k in base 3 is 0 (mod 3).

Original entry on oeis.org

0, 13, 14, 16, 17, 22, 23, 25, 26, 31, 32, 34, 35, 37, 38, 39, 42, 46, 47, 48, 51, 58, 59, 61, 62, 64, 65, 66, 69, 73, 74, 75, 78, 85, 86, 88, 89, 91, 92, 93, 96, 100, 101, 102, 105, 109, 110, 111, 114, 117, 126, 136, 137, 138, 141, 144, 153, 166, 167, 169, 170, 172, 173
Offset: 1

Views

Author

Carlos Alves, Jan 20 2003

Keywords

Comments

In base 2 this gives the "Evil Numbers" (cf. A001969) and slope 2. One may conjecture that in base b the asymptotic slope will be b and might suspect asymptotic density 1/b for each result (mod b). For nonprime b larger variations occur and "very big" numbers must be considered to believe in the conjecture (1 million or more...). (Related to A006287, here mod b is considered)

Examples

			59 is a member because 59 = 2013_3 and 2^2+0^2+1^2+1^2 = 6 = 0 (mod 3).
		

Crossrefs

Programs

  • Mathematica
    Ev = Function[{b, x}, vx = IntegerDigits[x, b]; Mod[vx.vx, b]]; Seq = Function[{b, n}, Flatten[Position[Table[Ev[b, k], {k, 1, n}], 0]]]; Seq[3, 1000]

Extensions

Revised by Sean A. Irvine, Aug 17 2025
Showing 1-4 of 4 results.