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.

Previous Showing 11-19 of 19 results.

A004759 Binary expansion starts 111.

Original entry on oeis.org

7, 14, 15, 28, 29, 30, 31, 56, 57, 58, 59, 60, 61, 62, 63, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244
Offset: 1

Views

Author

Keywords

Comments

This is the minimal recursive sequence such that a(1)=7, A007814(a(n))= A007814(n) and A010060(a(n))=A010060(n). - Vladimir Shevelev, Apr 23 2009

Examples

			30 in binary is 11110, so 30 is in sequence.
		

Crossrefs

Programs

  • Haskell
    import Data.List (transpose)
    a004759 n = a004759_list !! (n-1)
    a004759_list = 7 : concat (transpose [zs, map (+ 1) zs])
                       where zs = map (* 2) a004759_list
    -- Reinhard Zumkeller, Dec 03 2015
    
  • Mathematica
    w = {1, 1, 1}; Select[Range[5, 244], If[# < 2^(Length@ w - 1), True, Take[IntegerDigits[#, 2], Length@ w] == w] &] (* Michael De Vlieger, Aug 10 2016 *)
    Sort[FromDigits[#,2]&/@(Flatten[Table[Join[{1,1,1},#]&/@Tuples[{1,0},n],{n,0,5}],1])] (* Harvey P. Dale, Sep 01 2016 *)
  • PARI
    a(n)=n+6*2^floor(log(n)/log(2))
    
  • Python
    def A004759(n): return n+(3<Chai Wah Wu, Jul 13 2022

Formula

a(2n) = 2a(n), a(2n+1) = 2a(n) + 1 + 6[n==0].
a(n) = n + 6 * 2^floor(log_2(n)) = A004758(n) + A053644(n).
a(n+1) = min{m > a(n): A007814(m) = A007814(n+1) and A010060(m) = A010060(n+1)}. a(2^k) - a(2^k-1) = A103204(k+2), k >= 1. - Vladimir Shevelev, Apr 23 2009
a(2^m+k) = 7*2^m + k, m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Aug 08 2016

Extensions

Edited by Ralf Stephan, Oct 12 2003

A049971 a(n) = a(1) + a(2) + ... + a(n-1) + a(m) for n >= 4, where m = 2*n - 2 - 2^(p+1) and p is the unique integer such that 2^p < n - 1 <= 2^(p+1), starting with a(1) = 1, a(2) = 3, and a(3) = 2.

Original entry on oeis.org

1, 3, 2, 9, 24, 42, 90, 213, 597, 984, 1974, 3981, 8133, 17037, 37071, 87198, 244557, 401919, 803844, 1607721, 3215613, 6431997, 12866991, 25747038, 51564237, 103443195, 208092192, 421008660, 861332361, 1800360879, 3918287223, 9215926665, 25847419116, 42478911570, 84957823146
Offset: 1

Views

Author

Keywords

Examples

			a(5) = a(1) + a(2) + a(3) + a(4) + a(m) = 1 + 3 + 2 + 9 + a(m) = 15 + a(m). where m = 2*n - 2 - 2^(p+1) and 2^p < n - 1 = 4 <= 2^(p+1). We have p = 1 giving m = 2*5 - 2 - 4 = 4. As a(m) = a(4) = 9, we have a(5) = 15 + 9 = 24. - _David A. Corneth_, Apr 26 2020
		

Crossrefs

Cf. A049922 (similar, but with minus a(m/2)), A049923 (similar, but with minus a(m)), A049970 (similar, but with plus a(m/2)).

Programs

  • Maple
    s := proc(n) option remember; `if`(n < 1, 0, a(n) + s(n - 1)) end proc:
    a := proc(n) option remember;
    `if`(n < 4, [1, 3, 2][n], s(n - 1) + a(-2^ceil(log[2](n - 1)) + 2*n - 2)):
    end proc:
    seq(a(n), n = 1..40); # Petros Hadjicostas, Apr 25 2020
    # Alternative, uses A062050:
    a := proc(n) option remember; if n < 4 then [1, 3, 2][n] else
    add(a(i), i = 1..n-1 ) + a(2*A062050(n-2)) fi end:
    seq(a(n), n = 1..35); # Peter Luschny, Aug 06 2021
  • Mathematica
    a[1] = 1; a[2] = 3; a[3] = 2; a[n_] := a[n] = Sum[a[k], {k, 1, n - 1}] + a[2*n - 2 - 2^Floor[1 + Log[2, n - 2]]]; Table[a[n], {n, 1, 30}] (* Vaclav Kotesovec, Apr 26 2020 *)
  • PARI
    lista(nn) = { my(va = vector(nn)); va[1] = 1; va[2] = 3; va[3] = 2; my(sa = vecsum(va)); for (n=4, nn, va[n] = sa + va[2*n - 2 - 2*2^logint(n-2, 2)]; sa += va[n]; ); va; } \\ Michel Marcus, Apr 26 2020 (with nn > 2)
    
  • PARI
    first(n) = {n = max(n, 3); my(res = vector(n), s = 6, p = 1); res[1]  = 1; res[2] = 3; res[3] = 2; for(i = 4, n, if(i - 1 > 1 << (p + 1), p++); res[i] = s + res[2*i-2-2^(p+1)]; s += res[i]) ; res} \\ David A. Corneth, Apr 26 2020

Extensions

Name edited by Petros Hadjicostas, Apr 25 2020
More terms from David A. Corneth, Apr 26 2020

A092754 a(1)=1, a(2n)=2a(n)+1, a(2n+1)=2a(n)+2.

Original entry on oeis.org

1, 3, 4, 7, 8, 9, 10, 15, 16, 17, 18, 19, 20, 21, 22, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 127, 128, 129, 130, 131, 132
Offset: 1

Views

Author

Benoit Cloitre, Apr 13 2004

Keywords

Comments

More generally the sequence b(1)=1, b(2n)=2b(n)+x, b(2n+1)=2b(n)+y is given by the formula b(n)=A053644(n)+x*(n-A053644(n))+y*(A053644(n)-1).

Crossrefs

Cf. A053644 (x=y=0), A054429(x=-1, y=+1), A062050(x=+1, y=-1).
Cf. A206332 (complement).
Cf. A004754.

Programs

  • Haskell
    a092754 n = if n < 2 then n else 2 * a092754 n' + m + 1
                where (n',m) = divMod n 2
    a092754_list = map a092754 [1..]
    -- Reinhard Zumkeller, May 07 2012
  • PARI
    a(n)=if(n<2,1,if(n%2,a(n-1)+1,a(n/2)*2+1))
    
  • PARI
    a(n) = n + 1<Kevin Ryde, Jun 19 2021
    

Formula

a(n) = 2^floor(log(n)/log(2)) + n - 1.
a(n) = A004754(n) - 1. - Rémy Sigrist, May 05 2019

A107681 Repeat(first 2^k numbers with no 2 in ternary representation) for k>0.

Original entry on oeis.org

0, 1, 0, 1, 3, 4, 0, 1, 3, 4, 9, 10, 12, 13, 0, 1, 3, 4, 9, 10, 12, 13, 27, 28, 30, 31, 36, 37, 39, 40, 0, 1, 3, 4, 9, 10, 12, 13, 27, 28, 30, 31, 36, 37, 39, 40, 81, 82, 84, 85, 90, 91, 93, 94, 108, 109, 111, 112, 117, 118, 120, 121, 0, 1, 3, 4, 9, 10, 12, 13, 27, 28, 30, 31, 36, 37
Offset: 1

Views

Author

Reinhard Zumkeller, May 20 2005

Keywords

Comments

let A032924(n) = Sum(d(i)*3^i: 0
then .... a(n) = Sum((d(i)-1)*3^i: 0<=i
A032924(n) = A107680(n) + a(n);
A081604 (a(n)) <= A081604(A107680(n)) = A081604(A032924(n)) = A000523(n+1).

Examples

			A032924(177) = A107680(177) + a(177),
....... 1420 = ....... 1093 + 327,
.. '1221121' = ... '1111111'+ '110010',
............ = . A003462(7) + A005836(51).
		

Programs

  • PARI
    a(n)= fromdigits(binary(n+1-1<Ruud H.G. van Tol, Nov 18 2024
    
  • Python
    def A107681(n): return int(bin(n+1)[3:],3) # Chai Wah Wu, May 06 2025

Formula

a(n) = A005836(A062050(n+1)).

Extensions

Data corrected by Ruud H.G. van Tol, Nov 18 2024.

A152423 A variation of the Josephus problem, removing every other person, starting with person 1; a(n) is the last person remaining.

Original entry on oeis.org

1, 2, 2, 4, 2, 4, 6, 8, 2, 4, 6, 8, 10, 12, 14, 16, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20
Offset: 1

Author

Suttapong Wara-asawapati (retsam_krad(AT)hotmail.com), Dec 03 2008

Keywords

Comments

Begin with n people standing in a circle, numbered clockwise 1 through n. Until only one person remains, go around the circle clockwise, removing every other person, starting by removing person 1. a(n) is the number of the last person remaining.
Apparently a(n) = 2*A062050(n-1), n > 1. - Paul Curtz, May 30 2011

Examples

			From _Omar E. Pol_, Dec 16 2013: (Start)
It appears that this is also an irregular triangle with row lengths A011782 as shown below:
1;
2;
2,4;
2,4,6,8;
2,4,6,8,10,12,14,16;
2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32;
2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40, 42,44,46,48,50,52,54,56,58,60,62,64;
Right border gives A000079.
(End)
		

Crossrefs

The Index to the OEIS lists 21 entries under "Josephus problem". - N. J. A. Sloane, Dec 04 2008

Programs

  • Maple
    a:= n-> 2*n - 2^ceil(log[2](n)):
    seq(a(n), n=1..74);  # Alois P. Heinz, Nov 22 2023
  • Mathematica
    A152423[n_]:=2n-2^Ceiling[Log2[n]];Array[A152423,100] (* Paolo Xausa, Nov 23 2023 *)
  • PHP
    function F($in){ $a[1] = 1; if($in == 1){ return $a;} $temp =2; for($i=2;$i<=$in;$i++){ $temp+=2; if($temp>$i){ $temp = 2 ; } $answer[] = $temp; } return $answer; } #change $n value for the result $n=5; #sequence store in $answer by using $a = F($n); #to display a(n) echo $a[n];
    
  • Python
    m=len(bin(n))-3; print(n if 2**m==n else 2*(n-2**m)) # Nicolas Patrois, Apr 19 2021

Formula

a(1)=1, a(2)=2; for n > 2, a(n)=2 if n < a(n-1) + 2, otherwise a(n) = a(n-1) + 2.
a(n)=n if n is a power of 2, otherwise a(n)=2*(n-2^m) where m is the exponent of the nearest power of 2 below n. - Nicolas Patrois, Apr 19 2021
a(n) = 2*n - 2^ceiling(log_2(n)). - Alois P. Heinz, Nov 22 2023

Extensions

Edited by Jon E. Schoenfield, Feb 29 2020

A120241 a(n) = (n - 2^floor(log(n)/log(2)) + 1)-th integer among those positive integers not among the earlier terms of the sequence.

Original entry on oeis.org

1, 2, 4, 3, 6, 8, 10, 5, 9, 12, 14, 16, 18, 20, 22, 7, 13, 17, 21, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 11, 19, 25, 29, 33, 37, 41, 45, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 15, 27, 35, 43, 49, 53, 57, 61, 65
Offset: 1

Author

Leroy Quet, Jun 11 2006

Keywords

Comments

This sequence is a permutation of the positive integers. n - 2^floor(log(n)/log(2)) + 1 = A062050(n).

Examples

			The first 6 terms of the sequence are 1,2,4,3,6,8. Now 7 - 2^floor(log(7)/log(2)) + 1 = 4. So we want the 4th term of those positive integers not occurring among the first 6 terms of the sequence (i.e., the 4th term among 5,7,9,10,11,...). So a(7) = 10.
		

Crossrefs

Programs

  • Mathematica
    Fold[Append[#1, Complement[Range[Max[#1] + #2], #1][[#2]]] &, {1},
    Flatten@Table[Range[2^k], {k, 6}]] (* Ivan Neretin, Sep 24 2021 *)

Extensions

Extended by Ray Chandler, Jun 19 2006

A353292 a(n) is the number of positive integers k <= n that have at least one common 1-bit with n.

Original entry on oeis.org

0, 1, 1, 3, 1, 4, 5, 7, 1, 6, 7, 10, 9, 12, 13, 15, 1, 10, 11, 16, 13, 18, 19, 22, 17, 22, 23, 26, 25, 28, 29, 31, 1, 18, 19, 28, 21, 30, 31, 36, 25, 34, 35, 40, 37, 42, 43, 46, 33, 42, 43, 48, 45, 50, 51, 54, 49, 54, 55, 58, 57, 60, 61, 63, 1, 34, 35, 52, 37
Offset: 0

Author

Rémy Sigrist, Apr 09 2022

Keywords

Comments

See A353293 for the corresponding k's.

Examples

			For n = 10:
- we have:
      k   10 AND k
      --  --------
       1         0
       2         2
       3         2
       4         0
       5         0
       6         2
       7         2
       8         8
       9         8
      10        10
- so a(10) = #{2, 3, 6, 7, 8, 9, 10} = 7.
		

Crossrefs

Programs

  • PARI
    a(n) = { my (h=hammingweight(n), w=#binary(n)); n-2^(w-1)+1 + (2^(h-1)-1)*2^(w-h) }

Formula

a(n) = n - A115378(n) for any n > 0.
a(n) = A062050(n) + A088512(n) * A080100(n) for any n > 0.
a(2^k) = 1 for any k >= 0.
a(2^k - 1) = 2^k - 1 for any k >= 0.

A368531 Numbers whose binary indices are all powers of 3, where a binary index of n (row n of A048793) is any position of a 1 in its reversed binary expansion.

Original entry on oeis.org

0, 1, 4, 5, 256, 257, 260, 261, 67108864, 67108865, 67108868, 67108869, 67109120, 67109121, 67109124, 67109125, 1208925819614629174706176, 1208925819614629174706177, 1208925819614629174706180, 1208925819614629174706181, 1208925819614629174706432
Offset: 1

Author

Gus Wiseman, Dec 29 2023

Keywords

Comments

For powers of 2 instead of 3 we have A253317.

Examples

			The terms together with their binary expansions and binary indices begin:
         0:                           0 ~ {}
         1:                           1 ~ {1}
         4:                         100 ~ {3}
         5:                         101 ~ {1,3}
       256:                   100000000 ~ {9}
       257:                   100000001 ~ {1,9}
       260:                   100000100 ~ {3,9}
       261:                   100000101 ~ {1,3,9}
  67108864: 100000000000000000000000000 ~ {27}
  67108865: 100000000000000000000000001 ~ {1,27}
  67108868: 100000000000000000000000100 ~ {3,27}
  67108869: 100000000000000000000000101 ~ {1,3,27}
  67109120: 100000000000000000100000000 ~ {9,27}
  67109121: 100000000000000000100000001 ~ {1,9,27}
  67109124: 100000000000000000100000100 ~ {3,9,27}
  67109125: 100000000000000000100000101 ~ {1,3,9,27}
		

Crossrefs

A000244 lists powers of 3.
A048793 lists binary indices, length A000120, sum A029931.
A070939 gives length of binary expansion.
A096111 gives product of binary indices.

Programs

  • Mathematica
    Select[Range[0,10000],IntegerQ[Log[3,Times@@Join@@Position[Reverse[IntegerDigits[#,2]],1]]]&]
    (* Second program *)
    {0}~Join~Array[FromDigits[Reverse@ ReplacePart[ConstantArray[0, Max[#]], Map[# -> 1 &, #]], 2] &[3^(Position[Reverse@ IntegerDigits[#, 2], 1][[;; , 1]] - 1)] &, 255] (* Michael De Vlieger, Dec 29 2023 *)

Formula

a(3^n) = 2^(3^n - 1).

A333906 For n >= 2, a(n) = Sum_{k=2..n} prevpower2(k) + nextpower2(k) - 2*k, where prevpower2(k) is the largest power of 2 < k, nextpower2(k) is the smallest power of 2 > k.

Original entry on oeis.org

1, 1, 3, 5, 5, 3, 7, 13, 17, 19, 19, 17, 13, 7, 15, 29, 41, 51, 59, 65, 69, 71, 71, 69, 65, 59, 51, 41, 29, 15, 31, 61, 89, 115, 139, 161, 181, 199, 215, 229, 241, 251, 259, 265, 269, 271, 271, 269, 265, 259, 251, 241, 229, 215, 199, 181, 161
Offset: 2

Author

Ctibor O. Zizka, Apr 09 2020

Keywords

Comments

Partial sums of b(k) = prevpower2(k) + nextpower2(k) - 2*k; b(k) = 0 for A007283.

Examples

			a(2) = (1 + 4 - 2*2) = 1;
a(3) = (1 + 4 - 2*2) + (2 + 4 - 2*3) = 1;
a(4) = (1 + 4 - 2*2) + (2 + 4 - 2*3) + (2 + 8 - 2*4) = 3.
		

Crossrefs

Previous Showing 11-19 of 19 results.