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.

A067587 Inverse of A066884 considered as a permutation of the positive integers.

Original entry on oeis.org

1, 3, 2, 6, 5, 9, 4, 10, 14, 20, 8, 27, 13, 19, 7, 15, 35, 44, 26, 54, 34, 43, 12, 65, 53, 64, 18, 76, 25, 33, 11, 21, 77, 90, 89, 104, 103, 118, 42, 119, 134, 151, 52, 169, 63, 75, 17, 135, 188, 208, 88, 229, 102, 117, 24, 251, 133, 150, 32, 168, 41, 51, 16, 28, 152
Offset: 1

Views

Author

Jared Ricks (jaredricks(AT)yahoo.com), Jan 31 2002

Keywords

Crossrefs

Programs

  • Mathematica
    w[n_] := Plus@@IntegerDigits[n, 2]; p[n_] := Plus@@MapThread[Binomial, {Flatten[Position[Reverse[IntegerDigits[n, 2]], 1]]-1, Range[w[n]]}]; a[n_] := Binomial[w[n]+p[n], 2]+p[n]+1
  • PARI
    a(n)=my(w=hammingweight(n), p=sum(i=1, n-1, hammingweight(i)==w)); binomial(w+p, 2) + p + 1 \\ Jianing Song, Aug 06 2022
    
  • Perl
    foreach(1..10_000){$i=eval join "+", split //, sprintf "%b", $; $j=$r[$i]++; print "$ ",$j+1+($i+$j)*($i+$j-1)/2,"\n"} # Ivan Neretin, Mar 02 2016
    
  • Python
    from math import comb
    def A067587(n):
        c, k = 0, 0
        for i,j in enumerate(bin(n)[-1:1:-1]):
            if j == '1':
                k += 1
                c += comb(i,k)
        return comb(n.bit_count()+c,2)+c+1 # Chai Wah Wu, Mar 02 2023

Formula

Let w(n) = A000120(n) be the 'weight' of n; i.e. the number of 1's in the binary expansion of n. Let p(n) = A068076(n) be the number of positive integers < n with the same weight as n. Then a(n) = binomial(w(n)+p(n),2) + p(n) + 1.

Extensions

Edited by Dean Hickerson, Feb 16 2002
Offset changed to 1 by Ivan Neretin, Mar 02 2016

A067586 Number of 0's in the binary expansion of A066884(n+1).

Original entry on oeis.org

0, 0, 1, 0, 1, 2, 0, 1, 1, 3, 0, 1, 1, 2, 4, 0, 1, 1, 1, 2, 5, 0, 1, 1, 1, 2, 2, 6, 0, 1, 1, 1, 1, 2, 3, 7, 0, 1, 1, 1, 1, 2, 2, 3, 8, 0, 1, 1, 1, 1, 1, 2, 2, 3, 9, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 10, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 11, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 12, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2
Offset: 0

Views

Author

Jared Ricks (jaredricks(AT)yahoo.com), Jan 31 2002

Keywords

Programs

  • Mathematica
    a[n_] := Module[{}, r=Floor[(Sqrt[8n+1]-1)/2]; s=n-r*(r+1)/2; For[k=0, True, k++, If[s
    				

Extensions

Edited by Dean Hickerson, Feb 16 2002

A083140 Sieve of Eratosthenes arranged as an array and read by antidiagonals in the up direction; n-th row has property that smallest prime factor is prime(n).

Original entry on oeis.org

2, 3, 4, 5, 9, 6, 7, 25, 15, 8, 11, 49, 35, 21, 10, 13, 121, 77, 55, 27, 12, 17, 169, 143, 91, 65, 33, 14, 19, 289, 221, 187, 119, 85, 39, 16, 23, 361, 323, 247, 209, 133, 95, 45, 18, 29, 529, 437, 391, 299, 253, 161, 115, 51, 20, 31, 841, 667, 551, 493, 377, 319, 203, 125, 57, 22
Offset: 2

Views

Author

Yasutoshi Kohmoto, Jun 05 2003

Keywords

Comments

A permutation of natural numbers >= 2.
The proportion of integers in the n-th row of the array is given by A005867(n-1)/A002110(n) = A038110(n)/A038111(n). - Peter Kagey, Jun 03 2019, based on comments by Jamie Morken and discussion with Tom Hanlon.
The proportion of the integers after the n-th row of the array is given by A005867(n)/A002110(n). - Tom Hanlon, Jun 08 2019

Examples

			Array begins:
   2   4   6   8  10  12  14  16  18  20  22  24 .... (A005843 \ {0})
   3   9  15  21  27  33  39  45  51  57  63  69 .... (A016945)
   5  25  35  55  65  85  95 115 125 145 155 175 .... (A084967)
   7  49  77  91 119 133 161 203 217 259 287 301 .... (A084968)
  11 121 143 187 209 253 319 341 407 451 473 517 .... (A084969)
  13 169 221 247 299 377 403 481 533 559 611 689 .... (A084970)
		

Crossrefs

Cf. A083141 (main diagonal), A083221 (transpose), A004280, A038179, A084967, A084968, A084969, A084970, A084971.
Arrays of integers grouped into rows by various criteria:
by greatest prime factor: A125624,
by lowest prime factor: this sequence (upward antidiagonals), A083221 (downward antidiagonals),
by number of distinct prime factors: A125666,
by number of prime factors counted with multiplicity: A078840,
by prime signature: A095904,
by ordered prime signature: A096153,
by number of divisors: A119586,
by number of 1's in binary expansion: A066884 (upward), A067576 (downward),
by distance to next prime: A192179.

Programs

  • Mathematica
    a = Join[ {Table[2n, {n, 1, 12}]}, Table[ Take[ Prime[n]*Select[ Range[100], GCD[ Prime[n] #, Product[ Prime[i], {i, 1, n - 1}]] == 1 &], 12], {n, 2, 12}]]; Flatten[ Table[ a[[i, n - i]], {n, 2, 12}, {i, n - 1, 1, -1}]]
    (* second program: *)
    rows = 12; Clear[T]; Do[For[m = p = Prime[n]; k = 1, k <= rows, m += p, If[ FactorInteger[m][[1, 1]] == p, T[n, k++] = m]], {n, rows}]; Table[T[n - k + 1, k], {n, rows}, {k, n}] // Flatten (* Jean-François Alcover, Mar 08 2016 *)

Extensions

More terms from Hugo Pfoertner and Robert G. Wilson v, Jun 13 2003

A067576 Array T(i,j) read by downward antidiagonals, where T(i,j) is the j-th term whose binary expansion has i 1's.

Original entry on oeis.org

1, 2, 3, 4, 5, 7, 8, 6, 11, 15, 16, 9, 13, 23, 31, 32, 10, 14, 27, 47, 63, 64, 12, 19, 29, 55, 95, 127, 128, 17, 21, 30, 59, 111, 191, 255, 256, 18, 22, 39, 61, 119, 223, 383, 511, 512, 20, 25, 43, 62, 123, 239, 447, 767, 1023, 1024, 24, 26, 45, 79, 125, 247, 479, 895, 1535, 2047
Offset: 1

Views

Author

Robert G. Wilson v, Jan 30 2002

Keywords

Comments

This is a permutation of the positive integers; the inverse permutation is A356419. - Jianing Song, Aug 06 2022

Examples

			Array begins:
        j=1  j=2  j=3  j=4  j=5  j=6
  i=1:    1,   2,   4,   8,  16,  32, ...
  i=2:    3,   5,   6,   9,  10,  12, ...
  i=3:    7,  11,  13,  14,  19,  21, ...
  i=4:   15,  23,  27,  29,  30,  39, ...
  i=5:   31,  47,  55,  59,  61,  62, ...
  i=6:   63,  95, 111, 119, 123, 125, ...
		

Crossrefs

T(n,n) gives A036563(n+1).
The antidiagonals are read in the opposite direction from those in A066884.
Antidiagonal sums give A361074.

Programs

  • Mathematica
    a = {}; Do[ a = Append[a, Last[ Take[ Select[ Range[2^13], Count[ IntegerDigits[ #, 2], 1] == j & ], i - j]]], {i, 2, 12}, {j, 1, i - 1} ]; a

A207800 Permutation of positive numbers. See comments.

Original entry on oeis.org

1, 2, 3, 4, 7, 8, 5, 16, 15, 32, 6, 64, 11, 128, 9, 256, 31, 512, 10, 1024, 13, 2048, 12, 4096, 23, 8192, 17, 16384, 14, 32768, 18, 65536, 63, 131072, 20, 262144, 19, 524288, 24, 1048576, 27, 2097152, 33, 4194304, 21, 8388608, 34, 16777216, 47, 33554432, 36, 67108864, 22, 134217728, 40
Offset: 1

Views

Author

Keywords

Comments

a(1)=1; on places 2,4,6,8,... we put 2^m, m=1,2,3,..., i.e., numbers n with A000120(n)=1; on places 3,7,11,15,... we put numbers n with A000120(n)=2; on places 5,13,21,29,... we put numbers n with A000120(n)=3; etc.
For general description of the order, see comment in A207790.

Crossrefs

Cf. A207790.

Formula

a(n) = A066884(A209268(A065190(n))). Equivalently, a(n) = A067576(A249725(A065190(n))). - Ivan Neretin, Apr 30 2016

Extensions

a(30) corrected by Ivan Neretin, Apr 30 2016

A243109 a(n) is the largest number smaller than n and having the same Hamming weight as n, or n if no such number exist.

Original entry on oeis.org

0, 1, 1, 3, 2, 3, 5, 7, 4, 6, 9, 7, 10, 11, 13, 15, 8, 12, 17, 14, 18, 19, 21, 15, 20, 22, 25, 23, 26, 27, 29, 31, 16, 24, 33, 28, 34, 35, 37, 30, 36, 38, 41, 39, 42, 43, 45, 31, 40, 44, 49, 46, 50, 51, 53, 47, 52, 54, 57, 55, 58, 59, 61, 63, 32, 48, 65, 56, 66, 67, 69
Offset: 0

Views

Author

Philippe Beaudoin, Aug 20 2014

Keywords

Comments

To calculate a(n), some bits of n are rearranged. The lowest 1-bit which can move down is the 1 of the lowest 10 bit pair in n. This pair becomes 01 in a(n) and any 1's below there move up to immediately below so the decrease is as small as possible. If n has no 10 bit pair (n = 2^k-1) then nothing smaller is possible and a(n) = n. - Kevin Ryde, Mar 01 2021

Examples

			From _Kevin Ryde_, Mar 01 2021: (Start)
                           v    vv
     n = 1475 = binary 10111000011    lowest 10 of n
  a(n) = 1464 = binary 10110111000    becomes 01 and
                            ^^^       other 1's below
(End)
		

Crossrefs

Cf. A057168 (next of same weight), A066884 (array by weight), A241816 (lowest 10->01).

Programs

  • Mathematica
    A243109[n_] := If[# == 0, n, # - 2^(IntegerExponent[#, 2] - IntegerExponent[n+1, 2] - 1)] & [BitAnd[n, n+1]];
    Array[A243109, 100, 0] (* Paolo Xausa, Mar 07 2025 *)
  • PARI
    a(n) = {my(hn = hammingweight(n)); forstep(k=n-1, 1, -1, if (hammingweight(k) == hn, return (k)); ); return (n); } \\ Michel Marcus, Aug 20 2014
    
  • PARI
    a(n) = my(s=n+1,t=bitand(n,s)); if(t==0,n, t - 1<<(valuation(t,2)-valuation(s,2)-1)); \\ Kevin Ryde, Mar 01 2021
    
  • Python
    def A243109(n): return c if (c:=((~n&(b:=n-(a:=~n&n+1)))>>a.bit_length())^b) else n # Chai Wah Wu, Mar 06 2025

Formula

a(n) = t - 2^(A007814(t) - A007814(n+1) - 1) if t!=0, or a(n) = n if t=0, where t = A129760(n+1) is n with any trailing 1's cleared to 0's and A007814 is the 2-adic valuation. - Kevin Ryde, Mar 01 2021
For k,m > 0, a((2^k-1)*2^m) = 2^(m-1)*(2^(k+1)-3). - Chai Wah Wu, Mar 07 2025
If n is even, then a(n) = XOR(n,OR(a,a/2)) where a = AND(-n,n+1). - Chai Wah Wu, Mar 08 2025

A361074 Sum of the j-th number with binary weight n-j+1 over all j in [n].

Original entry on oeis.org

0, 1, 5, 16, 40, 92, 193, 401, 812, 1632, 3261, 6526, 13030, 26049, 52013, 103974, 207797, 415496, 830636, 1661086, 3321498, 6642591, 13283920, 26567121, 53131653, 106261922, 212518857, 425034976, 850060303, 1700115399, 3400211408, 6800412866, 13600787296
Offset: 0

Views

Author

Alois P. Heinz, Mar 01 2023

Keywords

Examples

			a(0) = 0 (empty sum).
a(1) = 1 = 1_2.
a(2) = 5 = 2 + 3 = 10_2 + 11_2.
a(3) = 16 = 4 + 5 + 7 = 100_2 + 101_2 + 111_2.
a(4) = 40 = 8 + 6 + 11 + 15 = 1000_2 + 110_2 + 1011_2 + 1111_2.
		

Crossrefs

Antidiagonal sums of A066884 or of A067576.

Programs

  • Maple
    b:= proc(i, j) option remember; uses Bits: local c, l, k;
          if j=1 then 2^i-1
        else c, l:= 0, [Split(b(i, j-1))[], 0];
             for k while l[k]<>1 or l[k+1]<>0 do c:=c+l[k] od;
             Join([1$c, 0$k-c, 1, l[k+2..-1][]])
          fi
        end:
    a:= n-> add(b(j, n-j+1), j=1..n):
    seq(a(n), n=0..32);

Formula

a(n) = Sum_{j=1..n} A066884(j,n-j+1) = Sum_{j=1..n} A067576(j,n-j+1).
Conjecture: a(n) ~ 19 * 2^n / 6. - Vaclav Kotesovec, Mar 04 2023
Showing 1-7 of 7 results.