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.

User: Andres M. Torres

Andres M. Torres's wiki page.

Andres M. Torres has authored 6 sequences.

A227643 a(0)=1; for n > 0, a(n) = 1 + Sum_{i=A228086(n)..A228087(n)} [A092391(i) = n]*a(i), where [] is the Iverson bracket, resulting in 1 when i + A000120(i) = n and 0 otherwise.

Original entry on oeis.org

1, 1, 2, 3, 1, 5, 1, 6, 2, 3, 7, 4, 8, 1, 13, 1, 2, 16, 1, 18, 2, 1, 21, 1, 2, 22, 3, 2, 23, 4, 1, 26, 1, 6, 2, 7, 29, 1, 37, 1, 2, 38, 3, 2, 39, 4, 1, 42, 1, 5, 3, 1, 48, 4, 1, 50, 1, 5, 2, 2, 51, 6, 3, 1, 54, 55, 7, 59, 8, 2, 68, 1, 3, 69, 4, 2, 70, 5, 1, 73, 1
Offset: 0

Author

Andres M. Torres, Jul 18 2013

Keywords

Comments

Each a(n) = 1 + the count of nodes in the finite subtree defined by the edge relation parent = child + A000120(child). In other words, one more than the count of n's descendants, by which we mean the whole transitive closure of all children emanating from the parent at n. The subtree is finite because successive descendant values get smaller and approach zero.

Examples

			0 has no children distinct from itself (we only have A092391(0)=0), so we define a(0) = (0+1) = 1,
1 has no children (it is one of the terms of A010061), so a(1) = (0+1) = 1,
4 and 6 are also members of A010061, so both a(4) and a(6) = (0+1) = 1,
7 has 1,2,3,4 and 5 among its descendants (as A092391(5)=7, A092391(3)=A092391(4)=5, A092391(2)=3, A092391(1)=2), so a(7) = (5+1) = 6,
8 has 6 as a child value,        so a(8) = (1+1) = 2,
9 has 6 and 8 as descendants,    so a(9) = (2+1) = 3,
10 has {1,2,3,4,5,7}             so a(10) = (6+1) = 7.
		

Crossrefs

Cf. A010061 (gives the positions of ones), A000120, A092391, A228082, A228083, A228085, A227359, A227361, A227408.
Cf. also A213727 for a descendant counts for a similar tree defined by the edge relation parent = child - A000120(child).

Programs

  • Scheme
    ;; A deficient definition which works only up to n=128:
    (definec (A227643deficient n) (cond ((zero? n) 1) ((zero? (A228085 n)) 1) ((= 1 (A228085 n)) (+ 1 (A227643deficient (A228086 n)))) ((= 2 (A228085 n)) (+ 1 (A227643deficient (A228086 n)) (A227643deficient (A228087 n)))) (else (error "Not yet implemented for cases where n has more than two immediate children!"))))
    ;; Another definition that works for all n, but is somewhat slower:
    (definec (A227643full n) (cond ((zero? n) 1) (else (+ 1 (add (lambda (i) (if (= (A092391 i) n) (A227643full i) 0)) (A228086 n) (A228087 n))))))
    ;; Auxiliary function add implements sum_{i=lowlim..uplim} intfun(i)
    (define (add intfun lowlim uplim) (let sumloop ((i lowlim) (res 0)) (cond ((> i uplim) res) (else (sumloop (1+ i) (+ res (intfun i)))))))
    ;; by Antti Karttunen, Aug 16 2013, macro definec can be found in his IntSeq-library.

Formula

From Antti Karttunen, Aug 16 2013: (Start)
a(0)=1; and for n > 0, if A228085(n)=0 then a(n)=1; if A228085(n)=1 then a(n)=1+a(A228086(n)); if A228085(n)=2 then a(n)=1+a(A228086(n))+a(A228087(n)); otherwise (when A228085(n)>2) cannot be computed with this formula, which works only up to n=128.
a(0)=1; and for n > 0, a(n) = 1+Sum_{i=A228086(n)..A228087(n)} [A092391(i) = n]*a(i). (Here [...] denotes the Iverson bracket, resulting in 1 when i+A000120(i) = n and 0 otherwise. This formula works with all n.) (End)

A227361 If n is even, then a(n) = n + bitsum(n), else a(n) = n - bitsum(n), where bitsum(n) is the count of binary 1's in n, A000120.

Original entry on oeis.org

0, 0, 3, 1, 5, 3, 8, 4, 9, 7, 12, 8, 14, 10, 17, 11, 17, 15, 20, 16, 22, 18, 25, 19, 26, 22, 29, 23, 31, 25, 34, 26, 33, 31, 36, 32, 38, 34, 41, 35, 42, 38, 45, 39, 47, 41, 50, 42, 50, 46, 53, 47, 55, 49, 58, 50, 59, 53, 62, 54, 64, 56, 67, 57, 65, 63, 68, 64, 70, 66, 73, 67, 74, 70, 77, 71, 79, 73, 82, 74, 82, 78, 85, 79, 87, 81, 90, 82, 91, 85
Offset: 0

Author

Andres M. Torres, Jul 08 2013

Keywords

Comments

I gathered together some interesting statistics for this seq A227361:
Within the first 200000001 members of this sequence, only 70 were repeated 4 times, and then only when n > 2 million. None were repeated 5 times.
The first value to become repeated 3 times is 50, occurring at indexes (n=) 46, 48, and 55.
The first value to become repeated 4 times is 2097170, occurring at indexes (n=) 2097150, 2097166, 2097168, and 2097175.
The total count of those only occurring once is 96226727, or about 48.11 %.
Total count of those repeated 2 times is 45055158.
Total count of those repeated 3 times is 4554221, or about 2.28 %.
Total count of those repeated 4 times is 70 (extremely low).
Repeatedly applying this BitStoneA(v) function to values in a recursive (nested) style has shown that only 21 starting values shall become zero. These are those values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 23, 27. All other values shall cycle forever in small loops.
274877906962 is the smallest number that occurs 5 times. - Donovan Johnson, Jul 27 2013

Examples

			a(0) = 0 because 0 is even, so 0 + bitsum(0) = 0.
a(1) = 0 because 1 is odd, so 1 - bitsum(1) = 0.
a(2) = 3 because 2 is even, so 2 + bitsum(2) = 3.
a(3) = 1 because 3 is odd, so 3 - bitsum(3) = 1.
		

Crossrefs

Programs

  • Blitz3D
    ;; Each a(n) is generated simply as follows:  a(n) = BitStoneA(n)
    Function BitStoneA(n)
             If  (n Mod 2)              ;; if is odd
                     Return n-bitsum(n)
             Else                       ;; if is even
                     Return n+bitsum(n)
             End If
    End Function
    ;; --- Or, If n is even, then return n+A000120(n), else return n-A000120(n), where A000120(n) = bitsum(n)
    
  • Mathematica
    Table[n + (-1)^n DigitCount[n, 2, 1], {n, 0, 127}] (* Alonso del Arte, Jul 08 2013 *)
  • PARI
    a(n)=n+(-1)^(n%2)*hammingweight(n) \\ Charles R Greathouse IV, Jul 09 2013

Formula

a(n) = n + (-1)^n * Sum_{j = 1 .. floor(log_2(n)) + 1} (floor(n/2^j + 1/2) - floor(n/2^j)). - Alonso del Arte, Jul 08 2013, based on one of Hieronymus Fischer's formulas for A000120.

A227542 a(n) is the number of all terms preceding a(n-1) that have the same even-odd parity as a(n-1).

Original entry on oeis.org

0, 0, 1, 0, 2, 3, 1, 2, 4, 5, 3, 4, 6, 7, 5, 6, 8, 9, 7, 8, 10, 11, 9, 10, 12, 13, 11, 12, 14, 15, 13, 14, 16, 17, 15, 16, 18, 19, 17, 18, 20, 21, 19, 20, 22, 23, 21, 22, 24, 25, 23, 24, 26, 27, 25, 26, 28, 29, 27, 28, 30, 31, 29, 30, 32, 33, 31, 32, 34, 35, 33, 34, 36, 37, 35, 36, 38, 39, 37, 38, 40, 41, 39, 40, 42, 43, 41, 42, 44, 45, 43, 44, 46
Offset: 0

Author

Andres M. Torres, Jul 15 2013

Keywords

Comments

If a(n-1) is even, a(n) is the count of all even members preceding a(n-1). If a(n-1) is odd, then a(n) is the count of all odd members preceding a(n-1).

Examples

			{0,0}        : a(1)=0, because no values exist before a(0)=0.
{0,0,1}      : a(2)=1, because 1 even value exists before a(1)=0.
{0,0,1,0}    : a(3)=0, because no odd values exist before a(2)=1.
{0,0,1,0,2}  : a(4)=2, because 2 even values exist before a(3)=0.
{0,0,1,0,2,3}: a(5)=3, because 3 even values exist before a(4)=2.
		

Programs

  • Blitz3D
    ;; [Blitz3D] Basic code
    ;; --a two index array to store counts of evens and odds
    Global EvenOdd[2]
    ;; store the sequence in an array
    Global a[10001]
    eo =0 ;; eo is a temporary variable
    a[1] = 0  ;; seq starts with "0"
    For z=1 To 10000  ;; create about 10000 values
         eo = isOdd(a[z])
         a[z+1] = EvenOdd[eo]
         EvenOdd[eo] = EvenOdd[eo] +1
    Next
    ;; returns 1 if v is ODD, else returns zero
    Function isOdd(v)
         Return v Mod 2
    End Function
    Function isEven(v)
         Return (v Mod 2)=0
    End Function
    
  • Maple
    A227542 := proc(n)
        option remember;
        local pari,a,i ;
        if n = 0 then
            0;
        else
            pari := type(procname(n-1),'even') ;
            a := 0 ;
            for i from 0 to n-2 do
                if type(procname(i),'even') = pari then
                    a := a+1 ;
                end if;
            end do:
            a ;
        end if;
    end proc: # R. J. Mathar, Jul 22 2013
  • Mathematica
    Join[{0,0,1},LinearRecurrence[{1,0,0,1,-1},{0,2,3,1,2},100]] (* Harvey P. Dale, Oct 01 2013 *)
  • PARI
    a(n) = if(n==1, 0, if(n==2, 1, (-3 - (-1)^n + (2+2*I)*(-I)^n + (2-I*2)*I^n + 2*n) / 4)) \\ Colin Barker, Oct 16 2015
    
  • PARI
    concat(vector(2), Vec((2*x^7-3*x^6+x^5+2*x^4-x^3+x^2)/(x^5-x^4-x+1) + O(x^100))) \\ Colin Barker, Oct 16 2015

Formula

G.f.: x^2 + x^4*(2+x-2*x^2+x^3) / ( (1+x)*(1+x^2)*(x-1)^2 ). - R. J. Mathar, Jul 22 2013
a(n) = (-3 - (-1)^n + (2+2*i)*(-i)^n + (2-i*2)*i^n + 2*n) / 4 for n>2, where i=sqrt(-1). - Colin Barker, Oct 16 2015

A227408 Set of all n, where n = r(s(n)) = s(r(n)), given that r(n) = n+bitcount(n), s(n) = n-bitcount(n), and bitcount(n) is the count of binary 1's in n.

Original entry on oeis.org

0, 22, 25, 38, 41, 70, 73, 134, 137, 237, 243, 262, 265, 365, 371, 429, 435, 461, 467, 492, 494, 498, 501, 518, 521, 621, 627, 685, 691, 717, 723, 748, 750, 754, 757, 813, 819, 845, 851, 876, 878, 882, 885, 909, 915, 940, 942, 946, 949, 972, 974, 978, 981, 988, 995, 1002, 1009, 1030, 1033, 1133, 1139, 1197, 1203, 1229
Offset: 1

Author

Andres M. Torres, Jul 10 2013

Keywords

Comments

This is a simple sequence where the nesting of functions r(n), and s(n), are grouped in a special way: n = r(s(n)) = s(r(n)), and those three values must be equal.

Examples

			0  = r(s(0)) = s(r(0))  = r(0)  = s(0)  = 0.
22 = r(s(22))= s(r(22)) = r(19) = s(25) = 22.
25 = r(s(25))= s(r(25)) = r(22) = s(28) = 25.
38 = r(s(38))= s(r(38)) = r(35) = s(41) = 38.
		

Crossrefs

Programs

  • PARI
    npbc(n) = n + hammingweight(n)
    nmbc(n) = n - hammingweight(n)
    isok(n) = (n == npbc(nmbc(n))) && (n == nmbc(npbc(n))) \\ Michel Marcus, Aug 08 2013

Formula

Find all n, such that: n = r(s(n)) = s(r(n)), where r(n) = n+bitcount(n) and s(n) = n-bitcount(n)

Extensions

Offset changed from 0 to 1 by Michel Marcus, Aug 08 2013

A227359 Natural numbers that are not of the form (k +- sum of binary digits of k) for any k.

Original entry on oeis.org

6, 13, 21, 30, 37, 48, 51, 80, 83, 111, 121, 133, 144, 147, 175, 185, 192, 207, 217, 226, 233, 242, 245, 248, 250, 272, 275, 303, 313, 320, 335, 345, 354, 361, 370, 373, 376, 378, 387, 399, 409, 418, 425, 434, 437, 440, 442, 457, 466, 469, 472, 474, 481, 488, 490, 497, 505, 507, 528, 531, 559, 569, 576, 591, 601, 610, 617
Offset: 1

Author

Andres M. Torres, Jul 08 2013

Keywords

Comments

This sequence is the intersection of sets A010061 and A055938, where: set A010061 is NONE of ( k + count of set binary bits(k) ), and set A055938 is NONE of ( k - count of set binary bits(k) ), for any k.
The numbers of terms not exceeding 10^k, for k = 1, 2, ..., are 1, 9, 127, 1362, 12921, 128429, 1261747, 12554142, 125697648, 1257065977, ... . Conjecture: This sequence has an asymptotic density (1/2) * A242403 = 0.126330... . - Amiram Eldar, Oct 02 2022

Examples

			Find the list of values not defined by:
V = i +- count of set binary bits(i), for any integer i.
Assume that setbits(n) returns the count of set binary digits of n.
A227359 sample: 6,13,21,30,37,48,51,80,83,111, ...
0 +- setbits(0) = 0     therefore 0 does not make the list
1 +- setbits(1) = 0,2   therefore 0 and 2 do not make the list
2 +- setbits(2) = 1,3   therefore 1 and 3 do not make the list
3 +- setbits(3) = 1,5   therefore 1 and 5 do not make the list
4 +- setbits(4) = 3,5   ...
5 +- setbits(5) = 3,7   therefore 3 and 7 do not make the list
6 +- setbits(6) = 4,8   therefore 4 and 8 do not make the list
7 +- setbits(7) = 4,10  therefore 4 and 10 do not make the list
8 +- setbits(8) = 7,9   therefore 7 and 9 do not make the list
6 and 13 did make the list because there is no solution for
6 = i +- setbits(i),  nor
13 = i +- setbits(i), for any integer i.
		

Crossrefs

Programs

  • Blitz3D
    ;; See link.

A226939 A recursive variation of the Collatz-Fibonacci sequence: a(n) = 1 + min(a(C(n)),a(C(C(n)))) where C(n) = A006370(n), the Collatz map.

Original entry on oeis.org

1, 1, 4, 2, 3, 5, 9, 2, 10, 4, 8, 5, 5, 9, 9, 3, 7, 11, 11, 4, 4, 8, 8, 6, 12, 6, 56, 10, 10, 10, 54, 3, 14, 7, 7, 11, 11, 11, 18, 5, 55, 5, 15, 9, 9, 9, 53, 6, 13, 13, 13, 6, 6, 57, 57, 10, 17, 10, 17, 10, 10, 54, 54, 4, 14, 14, 14, 8, 8, 8
Offset: 1

Author

Andres M. Torres, Jun 22 2013

Keywords

Comments

The sequence contains mysterious duplicates of terms, sometimes in groups of 2 to 4 at a time, but I haven't seen any cyclic patterns, it's all unique.

Examples

			a(n) values frequently depend on both lesser and higher terms:
a(3)= 1+ min( a(C(3)), a(C(C(3)))) = 4
a(3)= 1+ min( a(10), a(5))= 1+min(4,3) = 4
a(10)=1+ min( a(5), a(16))= 1+min(3,3) = 4
a(5) =1+ min( a(16),a(8)) = 1+min(3,2) = 3
a(16)=1+ min( a(8), a(4)) = 1+min(2,2) = 3
a(8) =1+ min( a(4), a(2)) = 1+min(1,1) = 2
a(4) =1+ min( a(2), a(1)) = 1+min(1,1) = 2
a(2) =1 (starting value)
		

Crossrefs

Cf. A014682.

Programs

  • Blitz3D
    function A(n)
                if n=1 or 2
                       return 1
                else
                       return 1 +lesser(A(C(n)), A(C(C(n))))
                end if
    end function
    ; The Collatz Sequence generator equation
    Function C(n)
           If n Mod 2
                     Return 3*n+1
           Else
                     Return n Shr 1
           End If
    End Function
    ;; Andres M. Torres, Jun 26 2013
  • PARI
    C(n)=if(n%2,3*n+1,n/2)
    A=vector(10^4);A[1]=A[2]=1;
    a(n)=if(n<=#A && A[n], A[n], my(c=C(n),t=min(a(c), a(C(c)))+1); if(n>#A, t, A[n]=t)) \\ Charles R Greathouse IV, Jun 24 2013
    

Formula

a(n) = 1 + min(a(C(n)), a(C(C(n)))), where C(n) = A006370(n).