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

A297770 Number of distinct runs in base-2 digits of n.

Original entry on oeis.org

1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 3, 2, 3, 2, 1, 2, 2, 3, 3, 3, 2, 3, 3, 2, 3, 3, 2, 2, 3, 2, 1, 2, 2, 3, 3, 2, 3, 4, 3, 3, 3, 2, 3, 4, 3, 3, 3, 2, 3, 4, 2, 4, 3, 2, 3, 2, 3, 3, 3, 2, 3, 2, 1, 2, 2, 3, 3, 3, 3, 4, 3, 3, 2, 3, 4, 3, 4, 4, 3, 3, 3, 3, 4, 3, 2, 3
Offset: 1

Views

Author

Clark Kimberling, Jan 26 2018

Keywords

Comments

Every positive integers occurs infinitely many times.
***
Guide to related sequences:
Base b # runs # distinct runs

Examples

			27 in base-2: 1,1,0,1,1; three runs, of which 2 are distinct:  0 and 11, so that a(27) = 2.
		

Crossrefs

Cf. A005811 (number of runs, not necessarily distinct).

Programs

  • Mathematica
    b = 2; s[n_] := Length[Union[Split[IntegerDigits[n, b]]]]
    Table[s[n], {n, 1, 200}]
  • PARI
    apply( {A297770(n)=my(r=[0,0], c); while(n, my(d=bitand(n,1), L=valuation(n+d, 2)); !bittest(r[1+d], L) && c++ && r[1+d] += 1<>=L); c}, [0..99]) \\ M. F. Hasler, Jul 13 2024
    
  • PARI
    a(n) = my(s=strjoin(binary(n)), v=vecsort(concat(strsplit(s, "1"), strsplit(s, "0")), , 8)); #v-(v[1]==""); \\ Ruud H.G. van Tol, Aug 05 2024
  • Python
    from itertools import groupby
    def A297770(n): return len(set(map(lambda x:tuple(x[1]),groupby(bin(n)[2:])))) # Chai Wah Wu, Jul 13 2024
    

A043567 Number of runs in base-15 representation of n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Every positive integers occurs infinitely many times. See A297770 for a guide to related sequences.

Examples

			For n = 226, its base-15 representation is "101" as 226 = 1*(15^2) + 0*(15^1) + 1*(15^0). "101" has three runs, thus a(226) = 3.
For n = 482, its base-15 representation is "222" as 482 = 2*(15^2) + 2*(15^1) + 2*(15^0). "222" has just one run, thus a(482) = 1.
		

Crossrefs

Cf. A043289, A043542, A297783 (number of distinct runs), A297770.

Programs

  • Mathematica
    Table[Length@ Split@ IntegerDigits[n, 15], {n, 0, 105}] (* Michael De Vlieger, Oct 10 2017 *)
  • Scheme
    (define (A043567 n) (let loop ((n n) (runs 1) (pd (modulo n 15))) (if (zero? n) runs (let ((d (modulo n 15))) (loop (/ (- n d) 15) (+ runs (if (not (= d pd)) 1 0)) d))))) ;; Antti Karttunen, Oct 10 2017

Extensions

More terms from Antti Karttunen, Oct 10 2017
Updated by Clark Kimberling, Feb 04 2018

A043568 Number of runs in base-16 representation of n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Differs from A043543 if we consider for example numbers which are palindromic in base 16 with 3 (2 distinct) digits. - R. J. Mathar, Oct 20 2008
Every positive integers occurs infinitely many times. See A297770 for a guide to related sequences. - Clark Kimberling, Feb 04 2018

Crossrefs

Cf. A297783 (number of distinct runs), A297770.

Programs

  • Mathematica
    b = 16; s[n_] := Length[Split[IntegerDigits[n, b]]];
    Table[s[n], {n, 0, 200}]
Showing 1-3 of 3 results.