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.

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

This page as a plain text file.
%I A067587 #30 Mar 02 2023 11:48:55
%S A067587 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,
%T A067587 18,76,25,33,11,21,77,90,89,104,103,118,42,119,134,151,52,169,63,75,
%U A067587 17,135,188,208,88,229,102,117,24,251,133,150,32,168,41,51,16,28,152
%N A067587 Inverse of A066884 considered as a permutation of the positive integers.
%H A067587 Ivan Neretin, <a href="/A067587/b067587.txt">Table of n, a(n) for n = 1..10000</a>
%H A067587 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A067587 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.
%t A067587 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
%o A067587 (Perl)
%o A067587 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
%o A067587 (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
%o A067587 (Python)
%o A067587 from math import comb
%o A067587 def A067587(n):
%o A067587     c, k = 0, 0
%o A067587     for i,j in enumerate(bin(n)[-1:1:-1]):
%o A067587         if j == '1':
%o A067587             k += 1
%o A067587             c += comb(i,k)
%o A067587     return comb(n.bit_count()+c,2)+c+1 # _Chai Wah Wu_, Mar 02 2023
%Y A067587 Cf. A066884, A000120, A068076, A263017, A356419.
%K A067587 nonn,look,easy
%O A067587 1,2
%A A067587 Jared Ricks (jaredricks(AT)yahoo.com), Jan 31 2002
%E A067587 Edited by _Dean Hickerson_, Feb 16 2002
%E A067587 Offset changed to 1 by _Ivan Neretin_, Mar 02 2016