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.

A112411 a(n) = smallest positive integer, not occurring earlier in the sequence and not equal to n, that has the same number of (non-leading) 0's in its binary representation as n.

This page as a plain text file.
%I A112411 #31 Mar 23 2024 08:24:22
%S A112411 3,5,1,9,2,11,15,17,4,12,6,10,14,13,7,33,8,20,21,18,19,25,27,35,22,28,
%T A112411 23,26,30,29,63,65,16,36,24,34,38,37,43,48,42,41,39,49,46,45,55,40,44,
%U A112411 52,53,50,51,57,47,71,54,60,61,58,59,95,31,129,32,68,69,66,67,73,56,80
%N A112411 a(n) = smallest positive integer, not occurring earlier in the sequence and not equal to n, that has the same number of (non-leading) 0's in its binary representation as n.
%C A112411 Sequence is a permutation of the positive integers. It is its own inverse permutation.
%H A112411 John Tyler Rascoe, <a href="/A112411/b112411.txt">Table of n, a(n) for n = 1..10000</a>
%H A112411 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%H A112411 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%e A112411 Among positive integers not among the first 8 terms of the sequence, 4 (100 in binary) is the smallest positive integer which has the same number of non-leading zeros in its binary representation as 9 (1001 in binary). So a(9) = 4.
%o A112411 (Python)
%o A112411 from itertools import islice
%o A112411 def val(n): return (~n & n-1).bit_length() # From Chai Wah Wu in A007814
%o A112411 def next0(n):
%o A112411     z = val(n)
%o A112411     f = (n|(2**z)-1) + 1
%o A112411     w = val(f)
%o A112411     if f != 2**w: z+=1
%o A112411     return(f|(2**(w-z)-1))
%o A112411 def a_gen():
%o A112411     B,n = [],1
%o A112411     while True:
%o A112411         f = 0
%o A112411         for i in B:
%o A112411             if i[0] == n:
%o A112411                 f+=1; n+=1; yield(i[1]); B.remove(i); break
%o A112411         if f < 1:
%o A112411             B.append((next0(n),n)); yield(next0(n)); n+=1
%o A112411 A112411_list = list(islice(a_gen(), 100)) # _John Tyler Rascoe_, Mar 20 2024
%Y A112411 Cf. A007814, A023416, A140977, A094510.
%K A112411 base,easy,nonn
%O A112411 1,1
%A A112411 _Leroy Quet_, Dec 08 2005
%E A112411 More terms from _R. J. Mathar_, Feb 08 2008